### Install PHP Watzap.id Client via Composer Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Install the library using Composer. Ensure you have Composer installed and configured for your project. ```bash composer require ay4t/php-watzap-id ``` -------------------------------- ### Get Webhook Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Retrieve the currently configured webhook URL for your Watzap ID account. This helps in verifying your webhook setup. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/get_webhook', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Handle Watzap.id API Exceptions Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Catch and handle `ApiException` to get detailed error information, including the message, HTTP status code, and response body. This is crucial for debugging and robust error management. ```php try { $response = $watzap->sendMessage('628123456789', 'Pesan'); } catch (ApiException $e) { echo "Error Message: " . $e->getMessage() . "\n"; echo "HTTP Status: " . $e->getHttpStatusCode() . "\n"; echo "Response Body: " . $e->getResponseBody() . "\n"; } ``` -------------------------------- ### Get Web Hook Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Endpoint to retrieve the currently set webhook URL. Requires API Key and Number Key. ```APIDOC ## POST https://api.watzap.id/v1/get_webhook ### Description Endpoint ini berfungsi untuk melihat Web Hook yang telah di set. ### Method POST ### Endpoint https://api.watzap.id/v1/get_webhook ### Parameters #### Request Body - **api_key** (string) - Required - Your API Key - **number_key** (string) - Required - Your Number Key ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY" } ``` ### Response #### Success Response (200) - **status** (string) - Description: Success status - **message** (string) - Description: The currently set webhook URL - **ack** (string) - Description: Acknowledgement of success ``` -------------------------------- ### Example Web Hook Request Body Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This JSON structure represents the data format received when a webhook is triggered by an incoming chat message. ```json { "type": "incoming_chat", "data": { "chat_id": "XXXXXXXXX", "message_id": "XXXXXXXXX", "name": "Nitami", "profile_picture": "https://example.com", "timestamp": 9283828329, "message_body": "Hi There", "message_ack": "PENDING", "has_media": false, "media_mime": "", "media_name": "", "location_attached": { "lat": null, "lng": null }, "is_forwading": false, "is_from_me": false } } ``` -------------------------------- ### Configure Watzap.id API Credentials Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Set up your API Key and Number Key in a .env file and load them into your PHP application using Dotenv. This is required for authenticating with the Watzap.id API. ```env API_KEY=your_api_key_here NUMBER_KEY=your_number_key_here ``` ```php use Dotenv\Dotenv; use Ay4t\WatzapId\Config\WatzapConfig; use Ay4t\WatzapId\WatzapClient; // Load environment variables $dotenv = Dotenv::createImmutable(__DIR__); $dotenv->load(); // Inisialisasi konfigurasi $config = new WatzapConfig(); $config->setApiKey($_ENV['API_KEY']) ->setNumberKey($_ENV['NUMBER_KEY']); // Buat instance WatzapClient $watzap = new WatzapClient($config); ``` -------------------------------- ### Set Webhook Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Configure a webhook to receive notifications from the Watzap ID service. Provide your site's URL as the endpoint. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["endpoint_url"] = "yoursite.com"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/set_webhook', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Send File using PHP Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This PHP script demonstrates how to send files (PDF, Word, Excel, CSV, video, image) using the Watzap ID API. It requires a public file URL and your API credentials. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["phone_no"] = "628xxxx"; $dataSending["url"] = "YOUR-PUBLIC-FILE-URL"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/send_file_url', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Set Web Hook Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Endpoint to set up a webhook URL for receiving notifications. Requires API Key, Number Key, and the endpoint URL. ```APIDOC ## POST https://api.watzap.id/v1/set_webhook ### Description Endpoint ini berfungsi untuk mengatur Web Hook. ### Method POST ### Endpoint https://api.watzap.id/v1/set_webhook ### Parameters #### Request Body - **api_key** (string) - Required - Your API Key - **number_key** (string) - Required - Your Number Key - **endpoint_url** (string) - Required - The URL of your webhook endpoint ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY", "endpoint_url": "YOUR-ENDPOINT-URL" } ``` ### Response #### Success Response (200) - **status** (string) - Description: Success status - **message** (string) - Description: Confirmation message including the set webhook URL - **ack** (string) - Description: Acknowledgement of success ``` -------------------------------- ### Check API Status with PHP Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Use this PHP script to verify if your API key is valid and the Watzap.id API is accessible. Ensure you replace 'xxxx' with your actual API key. ```php $dataSending = Array(); $dataSending["api-key"] = "xxxx"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/checking_key', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Send Image with Caption using PHP Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Use this PHP script to send an image with an optional caption via the Watzap ID API. Ensure you have a public image URL and valid API credentials. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["phone_no"] = "628xxxx"; $dataSending["message"] = "YOUR-MESSAGE"; $dataSending["url"] = "YOUR-PUBLIC-IMAGE-URL"; $dataSending["separate_caption"] = "(0 for No, 1 for Yes)"; $dataSending["wait_until_send"] = "1"; //This is an optional parameter, if you use this parameter the response will appear after sending the message is complete $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/send_image_url', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Send File Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This endpoint is used to send various types of files, including PDF, Word, Excel, CSV, videos, and images, to other WhatsApp users. ```APIDOC ## POST https://api.watzap.id/v1/send_file_url ### Description This endpoint sends various types of files, including PDF, Word, Excel, CSV, videos, and images, to other WhatsApp users. ### Method POST ### Endpoint https://api.watzap.id/v1/send_file_url ### Parameters #### Request Body - **api_key** (string) - Required - Your API key. - **number_key** (string) - Required - The assigned number key for your API. - **phone_no** (string) - Required - The recipient's phone number. - **url** (string) - Required - The public URL of the file to send. ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY", "phone_no": "628xxxx", "url": "YOUR-PUBLIC-FILE-URL" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation (e.g., "200"). - **message** (string) - A confirmation message (e.g., "Successfully"). - **ack** (string) - Acknowledgement of the operation (e.g., "successfully"). ``` -------------------------------- ### Manage and Message Groups Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Retrieve a list of groups and send messages or images to specific groups using their group IDs. Ensure you have the correct group ID. ```php // Ambil daftar grup try { $groups = $watzap->getGroups(); print_r($groups); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } // Kirim pesan ke grup try { $groupMessage = $watzap->sendGroupMessage( 'GROUP-ID@g.us', 'Halo semua! Ini adalah pesan grup.' ); print_r($groupMessage); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } // Kirim gambar ke grup try { $groupImage = $watzap->sendGroupImage( 'GROUP-ID@g.us', 'https://example.com/image.jpg', 'Caption untuk gambar grup' ); print_r($groupImage); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Send Image with Caption Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Send an image to a WhatsApp number, optionally with a caption. Provide the image URL and the caption text. ```php try { $imageMessage = $watzap->sendImage( '628123456789', 'https://example.com/image.jpg', 'Caption untuk gambar' ); print_r($imageMessage); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Check API Status Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This endpoint is used to verify if your API Key is valid and active. It helps in ensuring your integration is set up correctly. ```APIDOC ## POST /v1/checking_key ### Description Endpoint `checking_key` is useful for checking the status of your API Key, whether it is still VALID or NOT. ### Method POST ### Endpoint https://api.watzap.id/v1/checking_key ### Headers - `Content-Type`: application/json ### Request Body - **api_key** (string) - Required - Your Watzap.id API Key. ### Request Example ```json { "api_key": "YOUR-API-KEY" } ``` ### Response #### Success Response (200) - **data** (object) - Contains details about the API key and associated licenses. - **id** (string) - The ID of the API key. - **name** (string) - The name associated with the API key. - **email** (string) - The email address associated with the API key. - **expires_on** (string) - The expiration date of the API key. - **plan** (string) - The subscription plan. - **total_legacy_licenses** (string) - The amount of legacy numbers available. - **licenses_key** (array) - A list of license keys associated with the API key. - **id** (string) - The ID of the license. - **key** (string) - The license key. - **plan** (string) - The plan for this license. - **active_from** (string) - The date the license became active. - **active_until** (string) - The date the license expires. - **limit_message_per_day** (integer) - The limit for messages per day. - **expires_on** (string) - The expiration date for this license. - **limit_domain** (string) - The domain limit for this license. - **wa_number** (string) - The WhatsApp number associated with this license. - **is_connected** (boolean) - Indicates if the WhatsApp number is connected. - **status** (boolean) - Indicates if the request was successful. - **message** (string) - A message describing the result of the request. #### Response Example ```json { "data": { "id": "XXXXXXXX", "name": "WatZap.id", "email": "yourmail@mail.com", "expires_on": "27 April 2022 (41 days remaining)", "plan": "WatZap Premium", "total_legacy_licenses": "AMOUNT OF LEGACY NUMBER AVAILABLE", "licenses_key": [ { "id": "YOUR-NUMBERID", "key": "YOUR-KEY", "plan": "WatZap Premium", "active_from": "2021-05-04 00:00:00", "active_until": "2022-04-27 00:00:00", "limit_message_per_day": 0, "expires_on": "27 April 2022 (41 days remaining)", "limit_domain": "Unlimited", "wa_number": "628XXXXXXXX", "is_connected": true } ] }, "status": true, "message": "Successfully" } ``` ``` -------------------------------- ### Send File to Group Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Use this endpoint to send files (PDF, Word, Excel, CSV, video, images) to a specified group. Ensure you have a public URL for the file. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["group_id"] = "xxxxxxx@g.us"; $dataSending["url"] = "YOUR-PUBLIC-FILE-URL"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/send_file_group', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Send File (Group) Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Endpoint to send files (PDF, Word, Excel, CSV, video, image) to a specified group. Requires API Key, Number Key, Group ID, and a public file URL. ```APIDOC ## POST https://api.watzap.id/v1/send_file_group ### Description Endpoint ini berfungsi untuk mengirim pesan file yang memiliki format pdf/word/excel/csv/video/gambar yang akan dikirim ke Group yang anda inginkan. ### Method POST ### Endpoint https://api.watzap.id/v1/send_file_group ### Parameters #### Request Body - **api_key** (string) - Required - Your API Key - **number_key** (string) - Required - Your Number Key - **group_id** (string) - Required - The ID of the group to send the file to (e.g., xxxxxxx@g.us) - **url** (string) - Required - URL of the public file to send ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY", "group_id": "xxxxxxx@g.us", "url": "YOUR-PUBLIC-FILE-URL" } ``` ### Response #### Success Response (200) - **status** (string) - Description: Successfully sent status - **message** (string) - Description: Success message - **ack** (string) - Description: Acknowledgement of success ``` -------------------------------- ### Send Image with Caption Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Sends an image to a specified WhatsApp number along with an optional caption. ```APIDOC ## sendImage ### Description Sends an image with an optional caption to a specified WhatsApp number. ### Method `sendImage(string $number, string $imageUrl, string $caption = '')` ### Parameters #### Path Parameters - **number** (string) - Required - The recipient's WhatsApp number. - **imageUrl** (string) - Required - The URL of the image to send. - **caption** (string) - Optional - The caption for the image. Defaults to an empty string. ### Request Example ```php try { $imageMessage = $watzap->sendImage( '628123456789', 'https://example.com/image.jpg', 'Caption untuk gambar' ); print_r($imageMessage); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` ### Response Returns details about the sent image message. ``` -------------------------------- ### Group Features Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Provides methods for interacting with WhatsApp groups, including retrieving group lists and sending messages to groups. ```APIDOC ## Group Methods ### Description Methods for managing and sending messages to WhatsApp groups. ### Methods #### getGroups() Retrieves a list of groups the user is a part of. #### sendGroupMessage(string $groupId, string $message) Sends a text message to a specified group. - **groupId** (string) - Required - The ID of the group. - **message** (string) - Required - The content of the text message. #### sendGroupImage(string $groupId, string $imageUrl, string $caption = '') Sends an image with an optional caption to a specified group. - **groupId** (string) - Required - The ID of the group. - **imageUrl** (string) - Required - The URL of the image to send. - **caption** (string) - Optional - The caption for the image. ### Request Example ```php // Ambil daftar grup try { $groups = $watzap->getGroups(); print_r($groups); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } // Kirim pesan ke grup try { $groupMessage = $watzap->sendGroupMessage( 'GROUP-ID@g.us', 'Halo semua! Ini adalah pesan grup.' ); print_r($groupMessage); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } // Kirim gambar ke grup try { $groupImage = $watzap->sendGroupImage( 'GROUP-ID@g.us', 'https://example.com/image.jpg', 'Caption untuk gambar grup' ); print_r($groupImage); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` ### Response Returns details about the group operations. ``` -------------------------------- ### Check Watzap.id API Status Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Use this method to verify the current status of the Watzap.id API. It's recommended to wrap API calls in a try-catch block to handle potential exceptions. ```php try { $status = $watzap->checkApiStatus(); print_r($status); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Send Image (Group) Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Sends a message with an image (or only an image) to a specified group. Supports promotional content or general image messages. ```APIDOC ## POST /v1/send_image_group ### Description Sends a message with an image (or only an image) to a specified group. Supports promotional content or general image messages. ### Method POST ### Endpoint https://api.watzap.id/v1/send_image_group ### Parameters #### Request Body - **api_key** (string) - Required - Your Watzap ID API key. - **number_key** (string) - Required - The assigned number key for the API. - **group_id** (string) - Required - The ID of the target group (e.g., 'xxxxxxx@g.us'). - **url** (string) - Required - The public URL of the image to send. - **message** (string) - Optional - The text message to accompany the image. - **separate_caption** (string) - Optional - Set to '0' for No or '1' for Yes, to indicate if the caption should be separate. - **wait_until_send** (string) - Optional - If set to '1', the response will appear after the message sending is complete. ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY", "group_id": "xxxxxxx@g.us", "url": "YOUR-PUBLIC-IMAGE-URL", "message": "YOUR-MESSAGE", "separate_caption": "(0 for No, 1 for Yes)", "wait_until_send": "1" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation (e.g., '200'). - **message** (string) - A confirmation message (e.g., 'Successfully'). - **ack** (string) - Acknowledgement of the operation (e.g., 'successfully'). ``` -------------------------------- ### Send Text Message Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Send a plain text message to a WhatsApp number. The third parameter, if true, will wait for the message to be delivered. ```php try { $message = $watzap->sendMessage( '628123456789', 'Halo! Ini adalah pesan dari WatzapClient.', true // tunggu sampai pesan terkirim ); print_r($message); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Check API Status Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Checks the current status of the Watzap.id API. This method is useful for verifying API availability before performing other operations. ```APIDOC ## checkApiStatus ### Description Checks the current status of the Watzap.id API. ### Method `checkApiStatus()` ### Parameters None ### Request Example ```php try { $status = $watzap->checkApiStatus(); print_r($status); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` ### Response Returns the API status information. ``` -------------------------------- ### Send Text Message to Group Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Use this PHP script to send a text-only message to a specified group. Ensure you have a valid API key and number key. The 'wait_until_send' parameter is optional and controls when the response is returned. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["group_id"] = "xxxxxxx@g.us"; $dataSending["message"] = "YOUR-MESSAGE"; $dataSending["wait_until_send"] = "1"; //This is an optional parameter, if you use this parameter the response will appear after sending the message is complete $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/send_message_group', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Send Image to Group Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This PHP script allows sending an image, optionally with a text message, to a group. Provide a public URL for the image. The 'separate_caption' parameter determines if the message is sent separately from the image. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["group_id"] = "xxxxxxx@g.us"; $dataSending["message"] = "YOUR-MESSAGE"; $dataSending["url"] = "YOUR-PUBLIC-IMAGE-URL"; $dataSending["separate_caption"] = "(0 for No, 1 for Yes)"; $dataSending["wait_until_send"] = "1"; //This is an optional parameter, if you use this parameter the response will appear after sending the message is complete $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/send_image_group', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Send Text Message Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Sends a text message to a specified WhatsApp number. Optionally waits for confirmation of delivery. ```APIDOC ## sendMessage ### Description Sends a text message to a specified WhatsApp number. ### Method `sendMessage(string $number, string $message, bool $wait = false)` ### Parameters #### Path Parameters - **number** (string) - Required - The recipient's WhatsApp number. - **message** (string) - Required - The content of the text message. - **wait** (bool) - Optional - If true, the method will wait until the message is delivered. Defaults to false. ### Request Example ```php try { $message = $watzap->sendMessage( '628123456789', 'Halo! Ini adalah pesan dari WatzapClient.', true // tunggu sampai pesan terkirim ); print_r($message); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` ### Response Returns details about the sent message. ``` -------------------------------- ### Validate WhatsApp Number with PHP Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This PHP script checks if a given phone number is registered on WhatsApp. You need to provide your API key, number key, and the phone number to validate. Replace 'xxxx' placeholders with your actual credentials. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $dataSending["phone_no"] = "628xxxx"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/validate_number', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Unset Web Hook using PHP Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Use this PHP script to remove a previously set webhook. Ensure you have your API key and number key. ```php $dataSending = Array(); $dataSending["api_key"] = "xxxx"; $dataSending["number_key"] = "xxxx"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.watzap.id/v1/unset_webhook', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($dataSending), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Validate WhatsApp Number Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Validate a given WhatsApp number to ensure it is valid and registered. This function takes the phone number as a string argument. ```php try { $validation = $watzap->validateNumber('628123456789'); print_r($validation); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Send Text Message (Group) Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md Sends a text-only message to a specified group. This is useful for promotional content or general messages. ```APIDOC ## POST /v1/send_message_group ### Description Sends a text-only message to a specified group. This is useful for promotional content or general messages. ### Method POST ### Endpoint https://api.watzap.id/v1/send_message_group ### Parameters #### Request Body - **api_key** (string) - Required - Your Watzap ID API key. - **number_key** (string) - Required - The assigned number key for the API. - **group_id** (string) - Required - The ID of the target group (e.g., 'xxxxxxx@g.us'). - **message** (string) - Required - The text content of the message. - **wait_until_send** (string) - Optional - If set to '1', the response will appear after the message sending is complete. ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY", "group_id": "xxxxxxx@g.us", "message": "YOUR-MESSAGE", "wait_until_send": "1" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation (e.g., '200'). - **message** (string) - A confirmation message (e.g., 'Successfully'). - **ack** (string) - Acknowledgement of the operation (e.g., 'successfully'). ``` -------------------------------- ### Validate WhatsApp Number Source: https://github.com/ay4t/php-watzap-id/blob/main/README.md Validates a given WhatsApp number to ensure it is active and registered on WhatsApp. ```APIDOC ## validateNumber ### Description Validates a given WhatsApp number. ### Method `validateNumber(string $number)` ### Parameters #### Path Parameters - **number** (string) - Required - The WhatsApp number to validate (e.g., '628123456789'). ### Request Example ```php try { $validation = $watzap->validateNumber('628123456789'); print_r($validation); } catch (ApiException $e) { echo "Error: " . $e->getMessage(); } ``` ### Response Returns validation details for the provided number. ``` -------------------------------- ### Validate WhatsApp Number Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This endpoint checks if a given WhatsApp number is registered on WhatsApp. It requires your API key, a number key, and the phone number to validate. ```APIDOC ## POST /v1/validate_number ### Description This endpoint functions to check whether a number is registered on WhatsApp or not. The `Number Key` parameter can also be obtained from the API Key & Apps page in the Assigned Numbers for API section. ### Method POST ### Endpoint https://api.watzap.id/v1/validate_number ### Headers - `Content-Type`: application/json ### Request Body - **api_key** (string) - Required - Your Watzap.id API Key. - **number_key** (string) - Required - Your assigned number key for the API. - **phone_no** (string) - Required - The phone number to validate (e.g., 628xxxx). ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY", "phone_no": "628xxxx" } ``` ### Response #### Success Response (200) - **status** (string) - The status code of the response (e.g., "200"). - **message** (string) - A message describing the result (e.g., "Valid WhatsApp Number"). - **ack** (string) - Acknowledgment of the request processing (e.g., "successfully"). #### Response Example ```json { "status": "200", "message": "Valid WhatsApp Number", "ack": "successfully" } ``` ``` -------------------------------- ### Unset Web Hook Source: https://github.com/ay4t/php-watzap-id/blob/main/docs/README.md This endpoint is used to remove a previously set Web Hook. You can obtain the 'Number Key' from the API Key & Apps page under the Assigned Numbers for API section. ```APIDOC ## POST https://api.watzap.id/v1/unset_webhook ### Description Endpoint ini berfungsi untuk menghapus Web Hook yang telah di set. ### Method POST ### Endpoint https://api.watzap.id/v1/unset_webhook ### Parameters #### Request Body - **api_key** (string) - Required - Your API Key - **number_key** (string) - Required - The Number Key associated with your assigned number ### Request Example ```json { "api_key": "YOUR-API-KEY", "number_key": "YOUR-NUMBER-KEY" } ``` ### Response #### Success Response (200) - **status** (string) - Description: Indicates the status of the operation. - **message** (string) - Description: A message confirming the action. - **ack** (string) - Description: Acknowledgement of the action. #### Response Example ```json { "status": "200", "message": "Successfully Unset Web Hook", "ack": "successfully" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.