Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - vqoley

Pages: [1]
1
CWP API / Re: status invalid action
« on: July 18, 2024, 05:29:12 PM »
after i checked, there was problem with html code in admin panel. first, when try create there not ticking box for emails. when try update, that one is showing but when tick on any of that and click update, its nothing happen. so i create new again and change id in html for adminemails into emails id. i think this is bugs. please looks into it

2
CWP API / status invalid action
« on: July 18, 2024, 04:42:23 PM »
i have cwp pro. i try listing all email using api

Code: [Select]

// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);

// CWP API credentials and endpoint
$api_key = 'mykey';
$api_url = 'https://MYIP/v1/email';
$user = 'root';

// Data to be sent in the POST request
$data = array(
    "key" => $api_key,
    "action" => 'list',
    "user" => $user
);

// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Bypass SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Bypass hostname verification
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_POST, 1);

// Execute the API call
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

// Print the raw response for debugging
echo "Raw Response: " . htmlspecialchars($response) . "<br>";

// Decode the JSON response
$response_data = json_decode($response, true);

// Print the decoded response for debugging
echo "Decoded Response: ";
print_r($response_data);
echo "<br>";

// Check for errors
if ($response_data && isset($response_data['status']) && $response_data['status'] == 'OK') {
    // List email accounts
    if (!empty($response_data['msj'])) {
        foreach ($response_data['msj'] as $email_account) {
            echo 'Email: ' . $email_account['email'] . '<br>';
        }
    } else {
        echo 'No email accounts found.';
    }
} else {
    echo 'Failed to retrieve email accounts. Error: ' . json_encode($response_data);
}



after i excecuted my code, i got following error:

Code: [Select]
Raw Response: {"status":"Error","result":"invalid action"}
Decoded Response: Array ( [status] => Error [result] => invalid action )
Failed to retrieve email accounts. Error: {"status":"Error","result":"invalid action"}

please anyone help

Pages: [1]