### Install netflie/whatsapp-cloud-api using Composer Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Install the SDK using Composer. This command fetches the package and its dependencies. ```bash composer require netflie/whatsapp-cloud-api ``` -------------------------------- ### Install WhatsApp Cloud API SDK Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Install the SDK using Composer. Ensure your system meets the minimum requirements of PHP >= 7.4 and CURL >=7.19.4. ```bash composer require netflie/whatsapp-cloud-api ``` -------------------------------- ### Initialize WhatsAppCloudApi Client Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Instantiate the WhatsAppCloudApi client with your credentials. Minimal setup requires phone number ID and access token. Full setup can include business ID, Graph API version, and timeout. ```php '123456789012345', 'access_token' => 'EAABs...your-token', ]); // Full setup including business_id for template management $whatsapp = new WhatsAppCloudApi([ 'from_phone_number_id' => '123456789012345', 'access_token' => 'EAABs...your-token', 'business_id' => '987654321098765', 'graph_version' => 'v18.0', // default 'timeout' => 30, // seconds ]); ``` -------------------------------- ### Client Initialization Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Initialize the WhatsAppCloudApi client with your credentials. Minimal setup requires phone number ID and access token. Full setup can include business ID, Graph API version, and request timeout. ```APIDOC ## Client Initialization The main entry point. Accepts a configuration array with the phone number ID, access token, optional business ID (required for template management), Graph API version override, custom HTTP handler, and request timeout. ```php '123456789012345', 'access_token' => 'EAABs...your-token', ]); // Full setup including business_id for template management $whatsapp = new WhatsAppCloudApi([ 'from_phone_number_id' => '123456789012345', 'access_token' => 'EAABs...your-token', 'business_id' => '987654321098765', 'graph_version' => 'v18.0', // default 'timeout' => 30, // seconds ]); ``` ``` -------------------------------- ### Get Business Profile Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Retrieves the business profile information. Specify the fields you want to fetch. ```php businessProfile(''); ``` -------------------------------- ### Create a Message Template Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Creates a new message template for marketing, utility, or authentication purposes. Templates require a name, category, language, and components like headers, body, footers, and buttons. Examples for each component are included. ```php 'your-configured-from-phone-number-id', 'access_token' => 'your-facebook-whatsapp-application-token', 'business_id' => 'your-business-id', ]); $whatsapp->createTemplate( 'seasonal_promotion', 'MARKETING', // UTILITY | MARKETING | AUTHENTICATION 'en_US', [ [ 'type' => 'HEADER', 'format' => 'TEXT', 'text' => 'Our {{1}} is on!', 'example' => [ 'header_text' => ['Summer Sale'] ] ], [ 'type' => 'BODY', 'text' => 'Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.', 'example' => [ 'body_text' => [[ 'the end of August', '25OFF', '25%' ]] ] ], [ 'type' => 'FOOTER', 'text' => 'Use the buttons below to manage your marketing subscriptions' ], [ 'type' => 'BUTTONS', 'buttons' => [ [ 'type' => 'QUICK_REPLY', 'text' => 'Unsubscribe from Promos' ], [ 'type' => 'QUICK_REPLY', 'text' => 'Unsubscribe from All' ] ] ] ] ); ``` -------------------------------- ### Media File Management Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Upload a local file to Meta servers to get a reusable media ID, or download a remote media asset by its ID. Ensure the path to the local file is correct for uploads. ```php uploadMedia('/path/to/image.png'); $mediaId = new MediaObjectID($uploadResponse->decodedBody()['id']); $whatsapp->sendImage('34676104574', $mediaId, 'Uploaded image'); // Download a media file received in a webhook notification $downloadResponse = $whatsapp->downloadMedia('media-id-from-webhook'); file_put_contents('/tmp/received_image.jpg', $downloadResponse->body()); ``` -------------------------------- ### Get Business Profile Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Retrieves the business profile information for the WhatsApp Business account. ```APIDOC ## Get Business Profile ### Description Retrieves the business profile information. ### Method ```php $whatsapp_cloud_api->businessProfile(''); ``` ### Parameters #### Query Parameters - **fields** (string) - Required - Comma-separated list of fields to retrieve (e.g., 'about,email,profile_picture_url,name,websites,address,description,business_hours'). See [Fields list](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles) for available fields. ``` -------------------------------- ### Verify Webhook GET Request Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Validates the one-time GET request from Meta when registering a webhook URL. Ensure 'my-secret-verify-token' matches the token configured in the App Dashboard. ```php validate($_GET); // responseCode() is 200 on success, 403 on failure http_response_code($verificationRequest->responseCode()); echo $challenge; // Meta expects the hub.challenge value echoed back ``` -------------------------------- ### Webhook Verification Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Validates the one-time GET request from Meta when registering a webhook URL. It uses the `VerificationRequest` class to validate the incoming request and echo back the challenge token. ```APIDOC ## Webhook Verification — `VerificationRequest` Validates the one-time GET request that Meta sends when a webhook URL is registered in the App Dashboard. ```php validate($_GET); // responseCode() is 200 on success, 403 on failure http_response_code($verificationRequest->responseCode()); echo $challenge; // Meta expects the hub.challenge value echoed back ``` ``` -------------------------------- ### Instantiate Media with MediaType (PHP) Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md When directly instantiating the `Media` class, a new required `MediaType` parameter must be provided. Ensure a `MediaType` instance is passed as the eighth argument. ```php use Netflie\WhatsAppCloudApi\Message\Media\MediaType; new Media($id, $business, $image_id, $mime_type, $sha256, $filename, $caption, $received_at_timestamp); ``` ```php use Netflie\WhatsAppCloudApi\Message\Media\MediaType; new Media($id, $business, $image_id, $mime_type, $sha256, $filename, $caption, new MediaType('image'), $received_at_timestamp); ``` -------------------------------- ### Create and Update Templates (PHP) Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md Template management now requires a `business_id` in the `WhatsAppCloudApi` constructor. Use `createTemplate` to create new templates and `updateTemplateById` to modify existing ones. ```php $whatsapp = new WhatsAppCloudApi([ 'from_phone_number_id' => 'your-phone-number-id', 'access_token' => 'your-access-token', 'business_id' => 'your-business-id', ]); // Create a template $whatsapp->createTemplate('template_name', 'MARKETING', 'en_US', $components); // Update a template by ID $whatsapp->updateTemplateById('', $payload); ``` -------------------------------- ### Run Unit Tests Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Executes unit tests for the SDK. This command is typically run via Composer. ```bash composer unit-test ``` -------------------------------- ### Send Location Request Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Request the recipient's location. The message body can guide the user on how to share their location. ```php sendLocationRequest('', $body); ``` -------------------------------- ### Instantiate Context with Frequently Forwarded (PHP) Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md When directly instantiating the `Context` class, a new `frequently_forwarded` boolean parameter must be included between `$forwarded` and `$referred_product`. ```php new Context($replying_to_message_id, $forwarded, $referred_product); ``` ```php new Context($replying_to_message_id, $forwarded, $frequently_forwarded, $referred_product); ``` -------------------------------- ### Get Click ID in Referral Notifications Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md Retrieve the click ID from referral notifications using the ctwaClid() method on the referral object. ```php $notification->referral()->ctwaClid(); ``` -------------------------------- ### sendImage(), sendAudio(), sendVideo(), sendSticker() Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Methods for sending various media types. All accept a `LinkID` (public URL) or `MediaObjectID` (uploaded asset). Image and video support an optional caption. ```APIDOC ## sendImage() / sendAudio() / sendVideo() / sendSticker() — Send Media Messages All media types accept either a `LinkID` (public URL) or `MediaObjectID` (uploaded asset). Video and image accept an optional caption; sticker does not. ```php sendImage('34676104574', new LinkID('https://example.com/photo.jpg'), 'Product photo'); // Audio from uploaded media ID $whatsapp->sendAudio('34676104574', new MediaObjectID('9876543210')); // Video from URL $whatsapp->sendVideo('34676104574', new LinkID('https://example.com/intro.mp4'), 'Welcome video'); // Sticker from URL $whatsapp->sendSticker('34676104574', new LinkID('https://example.com/sticker.webp')); ``` ``` -------------------------------- ### Get Media Type in Webhook Notifications Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md Access the media type from webhook notifications using the type() method, which returns a MediaType enum instance. ```php $notification->type(); // returns a MediaType enum instance ``` -------------------------------- ### Create Template Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Creates a new message template for use with the WhatsApp Cloud API. ```APIDOC ## Create a Template ### Description Creates a new message template. ### Method ```php $whatsapp->createTemplate( 'seasonal_promotion', 'MARKETING', // UTILITY | MARKETING | AUTHENTICATION 'en_US', [ [ 'type' => 'HEADER', 'format' => 'TEXT', 'text' => 'Our {{1}} is on!', 'example' => [ 'header_text' => ['Summer Sale'] ] ], [ 'type' => 'BODY', 'text' => 'Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.', 'example' => [ 'body_text' => [[ 'the end of August', '25OFF', '25%' ]] ] ], [ 'type' => 'FOOTER', 'text' => 'Use the buttons below to manage your marketing subscriptions' ], [ 'type' => 'BUTTONS', 'buttons' => [ [ 'type' => 'QUICK_REPLY', 'text' => 'Unsubscribe from Promos' ], [ 'type' => 'QUICK_REPLY', 'text' => 'Unsubscribe from All' ] ] ] ] ); ``` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the template. - **category** (string) - Required - The category of the template (UTILITY, MARKETING, AUTHENTICATION). - **language** (string) - Required - The language of the template (e.g., 'en_US'). - **components** (array) - Required - An array of template components (HEADER, BODY, FOOTER, BUTTONS). ``` -------------------------------- ### Get Verification Request Response Code Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md After verifying a request, retrieve the HTTP status code using the responseCode() method. This is useful when headers have already been sent. ```php $verificationRequest = new VerificationRequest($verify_token); $challenge = $verificationRequest->verify($payload); $code = $verificationRequest->responseCode(); // 200 or 403 ``` -------------------------------- ### Run Integration Tests Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Executes integration tests that make real calls to the WhatsApp Cloud API. Ensure your testing credentials are set in the WhatsAppCloudApiTestConfiguration file before running. ```bash composer integration-test ``` -------------------------------- ### Media File Management Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Upload a local file to Meta servers (returns a reusable media ID) or download a remote media asset by its ID. ```APIDOC ## `uploadMedia()` / `downloadMedia()` — Media File Management Upload a local file to Meta servers (returns a reusable media ID); download a remote media asset by its ID. ```php uploadMedia('/path/to/image.png'); $mediaId = new MediaObjectID($uploadResponse->decodedBody()['id']); $whatsapp->sendImage('34676104574', $mediaId, 'Uploaded image'); // Download a media file received in a webhook notification $downloadResponse = $whatsapp->downloadMedia('media-id-from-webhook'); file_put_contents('/tmp/received_image.jpg', $downloadResponse->body()); ``` ``` -------------------------------- ### Instantiate Referral with CTWA CLID (PHP) Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md When directly instantiating the `Referral` class, a new required `ctwa_clid` string parameter must be appended as the last argument. ```php new Referral($source_id, $source_url, $source_type, $headline, $body, $media_type, $media_url, $thumbnail_url); ``` ```php new Referral($source_id, $source_url, $source_type, $headline, $body, $media_type, $media_url, $thumbnail_url, $ctwa_clid); ``` -------------------------------- ### Upload Media Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Uploads a media file to WhatsApp servers and returns a media ID. ```APIDOC ## Upload media resources ### Description Uploads a media file to WhatsApp servers and returns a media ID that can be used to send the media. ### Method POST (Implied by SDK method) ### Endpoint Not explicitly defined, SDK method `uploadMedia` is used. ### Parameters - **file_path** (string) - Required - The path to the media file to upload. ### Request Example ```php uploadMedia('my-image.png'); $media_id = new MediaObjectID($response->decodedBody()['id']); $whatsapp_cloud_api->sendImage('', $media_id); ?> ``` ### Response - **id** (string) - The ID of the uploaded media resource. ``` -------------------------------- ### sendTemplate() Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends a pre-approved WhatsApp message template. Dynamic parameters can be injected into header, body, and button components. ```APIDOC ## `sendTemplate()` — Send a Template Message Sends a pre-approved WhatsApp message template. Pass a `Component` object to inject dynamic parameters into header, body, and button components. ```php sendTemplate('34676104574', 'hello_world', 'en_US'); // Template with dynamic parameters and quick-reply buttons $component_body = [ ['type' => 'text', 'text' => 'Mr. Jones'], ]; $component_buttons = [ ['type' => 'button', 'sub_type' => 'quick_reply', 'index' => 0, 'parameters' => [['type' => 'text', 'text' => 'Yes']]], ['type' => 'button', 'sub_type' => 'quick_reply', 'index' => 1, 'parameters' => [['type' => 'text', 'text' => 'No']]], ]; $components = new Component([], $component_body, $component_buttons); $response = $whatsapp->sendTemplate('34676104574', 'sample_issue_resolution', 'en_US', $components); echo $response->decodedBody()['messages'][0]['id']; ``` ``` -------------------------------- ### Send Template Message with Parameters and Buttons Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a template message with custom header, body, and buttons. Parameters can be text, and buttons can be quick replies. ```php 'text', 'text' => '*Mr Jones*', ], ]; $component_buttons = [ [ 'type' => 'button', 'sub_type' => 'quick_reply', 'index' => 0, 'parameters' => [ [ 'type' => 'text', 'text' => 'Yes', ] ] ], [ 'type' => 'button', 'sub_type' => 'quick_reply', 'index' => 1, 'parameters' => [ [ 'type' => 'text', 'text' => 'No', ] ] ] ]; $components = new Component($component_header, $component_body, $component_buttons); $whatsapp_cloud_api->sendTemplate('34676104574', 'sample_issue_resolution', 'en_US', $components); // Language is optional ``` -------------------------------- ### Download Media Resource with WhatsApp Cloud API Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Download a media resource using its media ID. The response will contain the media content. ```php $response = $whatsapp_cloud_api->downloadMedia(''); ``` -------------------------------- ### Download Media Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Downloads a media resource from WhatsApp servers using its media ID. ```APIDOC ## Download media resources ### Description Downloads a media resource from WhatsApp servers using its media ID. ### Method GET (Implied by SDK method) ### Endpoint Not explicitly defined, SDK method `downloadMedia` is used. ### Parameters - **media_id** (string) - Required - The ID of the media resource to download. ### Request Example ```php downloadMedia(''); ?> ``` ### Response Response details not explicitly provided in the source. The response likely contains the media content. ``` -------------------------------- ### sendButton() Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends up to three quick-reply buttons beneath a message body. ```APIDOC ## `sendButton()` — Send an Interactive Button Reply Sends up to three quick-reply buttons beneath a message body. ```php sendButton( '34676104574', 'Would you like to rate us on Trustpilot?', $action, 'RATE US', // optional header text 'Choose an option' // optional footer text ); ``` ``` -------------------------------- ### Upload Media and Send Image with WhatsApp Cloud API Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Upload media files to WhatsApp servers and then send the media using the returned ID. Requires the media file to be publicly accessible or uploaded first. ```php $response = $whatsapp_cloud_api->uploadMedia('my-image.png'); $media_id = new MediaObjectID($response->decodedBody()['id']); $whatsapp_cloud_api->sendImage('', $media_id); ``` -------------------------------- ### Send Template Message - With Parameters and Buttons Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends a template message with dynamic parameters in the body and quick-reply buttons. The `Component` object is used to structure these dynamic elements. ```php 'text', 'text' => 'Mr. Jones'], ]; $component_buttons = [ ['type' => 'button', 'sub_type' => 'quick_reply', 'index' => 0, 'parameters' => [['type' => 'text', 'text' => 'Yes']]], ['type' => 'button', 'sub_type' => 'quick_reply', 'index' => 1, 'parameters' => [['type' => 'text', 'text' => 'No']]], ]; $components = new Component([], $component_body, $component_buttons); $response = $whatsapp->sendTemplate('34676104574', 'sample_issue_resolution', 'en_US', $components); echo $response->decodedBody()['messages'][0]['id']; ``` -------------------------------- ### Template Management Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Create new message templates or update existing ones via the Business API. Requires `business_id` in the constructor config. ```APIDOC ## `createTemplate()` / `updateTemplateById()` — Template Management Create new message templates or update existing ones via the Business API. Requires `business_id` in the constructor config. ```php createTemplate( 'seasonal_promo', 'MARKETING', // MARKETING | UTILITY | AUTHENTICATION 'en_US', [ ['type' => 'HEADER', 'format' => 'TEXT', 'text' => 'Our {{1}} is on!', 'example' => ['header_text' => ['Summer Sale']]], ['type' => 'BODY', 'text' => 'Use code {{1}} to get {{2}} off.', 'example' => ['body_text' => [['SAVE25', '25%']]]], ['type' => 'FOOTER', 'text' => 'Manage subscriptions below.'], ['type' => 'BUTTONS', 'buttons' => [ ['type' => 'QUICK_REPLY', 'text' => 'Unsubscribe'], ]], ] ); // Update an existing template $whatsapp->updateTemplateById('template-id-12345', [ 'category' => 'MARKETING', 'language' => 'en_US', 'components' => [ ['type' => 'BODY', 'text' => 'Use code {{1}} for {{2}} off until {{3}}.', 'example' => ['body_text' => [['FLASH30', '30%', 'Sunday']]]], ], ]); ``` ``` -------------------------------- ### Send Single and Multi-Product Messages Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Use `sendSingleProduct` to send a message with one product from a catalog. Use `sendMultiProduct` to group multiple products into sections from a catalog. ```php sendSingleProduct( '34676104574', 123456789, // catalog_id (int) 'SKU-CHAIR-RED', // product_retailer_id 'Here is the item you asked about.', 'Subject to availability.' ); // Multi product use Netflie\WhatsAppCloudApi\Message\MultiProduct\Row; use Netflie\WhatsAppCloudApi\Message\MultiProduct\Section; use Netflie\WhatsAppCloudApi\Message\MultiProduct\Action; $action = new Action([ new Section('Furniture', [new Row('SKU-CHAIR-RED'), new Row('SKU-TABLE-OAK')]), new Section('Lighting', [new Row('SKU-LAMP-001'), new Row('SKU-LAMP-002')]) ]); $whatsapp->sendMultiProduct( '34676104574', 123456789, $action, 'Grocery Collections', "Here's what we can offer you. Thank you for shopping with us.", 'Subject to T&C' ); ``` -------------------------------- ### Send List Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a message with a list of options, organized into sections, allowing users to select an item. Requires defining rows, sections, and an action. ```php sendList( '', 'Rate your experience', 'Please consider rating your shopping experience in our website', 'Thanks for your time', $action ); ``` -------------------------------- ### Send Catalog Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a catalog message to showcase products. Can include a body, footer, and a product SKU ID for the header thumbnail. ```php '; // product sku id to use as header thumbnail $whatsapp_cloud_api->sendCatalog( '', $body, $footer, // optional $sku_thumbnail // optional ); ``` -------------------------------- ### Send Media Messages (Image, Audio, Video, Sticker) Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Send various media types using either a public URL (`LinkID`) or an uploaded media ID (`MediaObjectID`). Images and videos can include a caption; stickers do not. ```php sendImage('34676104574', new LinkID('https://example.com/photo.jpg'), 'Product photo'); // Audio from uploaded media ID $whatsapp->sendAudio('34676104574', new MediaObjectID('9876543210')); // Video from URL $whatsapp->sendVideo('34676104574', new LinkID('https://example.com/intro.mp4'), 'Welcome video'); // Sticker from URL $whatsapp->sendSticker('34676104574', new LinkID('https://example.com/sticker.webp')); ``` -------------------------------- ### Send Multi-Product Message with WhatsApp Cloud API Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Use this to send a multi-product message to a recipient. Requires catalog and product SKU IDs, along with message content and optional footer. ```php '), new Row(''), // etc ]; $rows_section_2 = [ new Row(''), new Row(''), new Row(''), // etc ]; $sections = [ new Section('Section 1', $rows_section_1), new Section('Section 2', $rows_section_2), ]; $action = new Action($sections); $catalog_id = ''; $header = 'Grocery Collections'; $body = 'Hello! Thanks for your interest. Here\'s what we can offer you under our grocery collection. Thank you for shopping with us.'; $footer = 'Subject to T&C'; $whatsapp_cloud_api->sendMultiProduct( '', $catalog_id, $action, $header, $body, $footer // optional ); ``` -------------------------------- ### Send Interactive Options List Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends a message with a scrollable list of selectable rows, grouped into sections. Requires defining rows, sections, and an action. ```php sendList( '34676104574', 'Rate your experience', 'Please rate your recent shopping experience.', 'Thank you for your time', $action ); ``` -------------------------------- ### Template Management Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Create new message templates or update existing ones via the Business API. Requires `business_id` in the constructor config. Specify the template category, language, and components. ```php createTemplate( 'seasonal_promo', 'MARKETING', // MARKETING | UTILITY | AUTHENTICATION 'en_US', [ ['type' => 'HEADER', 'format' => 'TEXT', 'text' => 'Our {{1}} is on!', 'example' => ['header_text' => ['Summer Sale']]], ['type' => 'BODY', 'text' => 'Use code {{1}} to get {{2}} off.', 'example' => ['body_text' => [['SAVE25', '25%']]]], ['type' => 'FOOTER', 'text' => 'Manage subscriptions below.'], ['type' => 'BUTTONS', 'buttons' => [ ['type' => 'QUICK_REPLY', 'text' => 'Unsubscribe'], ]], ] ); // Update an existing template $whatsapp->updateTemplateById('template-id-12345', [ 'category' => 'MARKETING', 'language' => 'en_US', 'components' => [ ['type' => 'BODY', 'text' => 'Use code {{1}} for {{2}} off until {{3}}.', 'example' => ['body_text' => [['FLASH30', '30%', 'Sunday']]]], ], ]); ``` -------------------------------- ### Business Profile Management Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Retrieve specific WhatsApp Business profile fields or update them. Ensure the `business_id` is configured in the constructor for profile updates. ```php businessProfile('about,email,address,description,websites'); print_r($response->decodedBody()); // ['data' => [['about' => 'We sell furniture', 'email' => 'hi@example.com', ...]]] // Update profile fields $whatsapp->updateBusinessProfile([ 'about' => 'The best furniture store on WhatsApp.', 'email' => 'support@example.com', 'address' => '123 Main Street, Springfield', 'websites' => ['https://example.com'], ]); ``` -------------------------------- ### Send Single Product Message (PHP) Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md Use the `sendSingleProduct` method to send a single product message. Requires destination phone number, catalog ID, product SKU ID, and optional body and footer text. ```php $whatsapp_cloud_api->sendSingleProduct( '', '', '', 'Optional body text', 'Optional footer text' ); ``` -------------------------------- ### Send Contact Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send contact information including name and phone number. Phone numbers should include the country code. ```php sendContact('', $name, null, $phone); ``` -------------------------------- ### Send Text Message with Error Handling Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a text message and catch potential ResponseExceptions from WhatsApp servers. Allows inspection of the response even on error. ```php try { $response = $this->whatsapp_app_cloud_api->sendTextMessage( ', 'Hey there! I\'m using WhatsApp Cloud API. Visit https://www.netflie.es', true ); } catch ( Netflie\WhatsAppCloudApi\Response\ResponseException $e) { print_r($e->response()); // You can still check the Response returned from Meta servers } ``` -------------------------------- ### Send Single Product Message with WhatsApp Cloud API Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a single product message to a recipient. Requires catalog ID, product SKU ID, and optional body and footer text. ```php '; $sku_id = ''; $body = 'Hello! Here\'s your requested product. Thanks for shopping with us.'; $footer = 'Subject to T&C'; $whatsapp_cloud_api->sendSingleProduct( '', $catalog_id, $sku_id, $body, // body: optional $footer // footer: optional ); ``` -------------------------------- ### Send Catalog Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a message showcasing products from a catalog, with optional body, footer, and thumbnail. ```APIDOC ## Send Catalog Message ### Description Send a message that displays products from your catalog. You can include a body text, an optional footer, and specify a product SKU to use as a header thumbnail. ### Method `sendCatalog(string $recipient, string $body, string $footer = null, string $sku_thumbnail = null)` ### Parameters #### Path Parameters - **recipient** (string) - Required - The recipient's phone number. - **body** (string) - Required - The main text content of the catalog message. - **footer** (string) - Optional - The footer text for the catalog message. - **sku_thumbnail** (string) - Optional - The product SKU ID to use as the header thumbnail. ### Request Example ```php '; // product sku id to use as header thumbnail $whatsapp_cloud_api->sendCatalog( '', $body, $footer, // optional $sku_thumbnail // optional ); ?> ``` ``` -------------------------------- ### Send Audio Message with WhatsApp Cloud API SDK Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send an audio message using a direct link to the audio file. The LinkID class is used to specify the audio URL. ```php sendAudio('34676104574', $link_id); ``` -------------------------------- ### sendLocation() / sendLocationRequest() Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt `sendLocation` pushes a map pin; `sendLocationRequest` asks the recipient to share their own location. ```APIDOC ## `sendLocation()` / `sendLocationRequest()` — Send Location Messages `sendLocation` pushes a map pin; `sendLocationRequest` asks the recipient to share their own location. ```php sendLocation( '34676104574', -3.70325, // longitude 40.41650, // latitude 'Puerta del Sol', 'Plaza de la Puerta del Sol, Madrid, Spain' ); // Ask the user to share their location $whatsapp->sendLocationRequest( '34676104574', "Let's start with your pickup. You can *enter an address* or *share your current location*." ); ``` ``` -------------------------------- ### Send Document Message with WhatsApp Cloud API SDK Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a document message by either uploading a file to WhatsApp servers (using MediaObjectID) or by providing a direct link to the document (using LinkID). ```php sendDocument('34676104574', $media_id, $document_name, $document_caption); // Or $document_link = 'https://netflie.es/wp-content/uploads/2022/05/image.png'; $link_id = new LinkID($document_link); $whatsapp_cloud_api->sendDocument('34676104574', $link_id, $document_name, $document_caption); ``` -------------------------------- ### Send Template Message - Simple Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends a simple template message with no dynamic parameters. Ensure the template name and language code are correct. ```php sendTemplate('34676104574', 'hello_world', 'en_US'); ``` -------------------------------- ### Send Video Message using Link or Media ID Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a video message by providing a URL or a Media Object ID. Ensure the URL is accessible and the Media Object ID is valid. ```php sendVideo('', $link_id, ''); //or $media_id = new MediaObjectID(''); $whatsapp_cloud_api->sendVideo('', $media_id, ''); ``` -------------------------------- ### sendList() Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends an interactive message with a scrollable list of selectable rows grouped into sections. ```APIDOC ## `sendList()` — Send an Interactive Options List Sends an interactive message with a scrollable list of selectable rows grouped into sections. ```php sendList( '34676104574', 'Rate your experience', 'Please rate your recent shopping experience.', 'Thank you for your time', $action ); ``` ``` -------------------------------- ### sendCatalog() Source: https://context7.com/netflie/whatsapp-cloud-api/llms.txt Sends a message with a "View Catalog" button linked to the business's Meta Commerce catalog. ```APIDOC ## `sendCatalog()` — Send a Catalog Message Sends a message with a "View Catalog" button linked to the business's Meta Commerce catalog. ```php sendCatalog( '34676104574', "Thanks for your interest! Browse our catalog below.", 'Best deals on WhatsApp!', // optional footer 'SKU-THUMBNAIL-001' // optional: product SKU to use as header thumbnail ); ``` ``` -------------------------------- ### Send Template Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Sends a pre-defined template message to a WhatsApp user. Templates can be simple or include dynamic components. ```APIDOC ## Send Template Message ### Description Sends a template message to a specified recipient. ### Method ```php public function sendTemplate(string $recipient, string $template_name, string $language, ?\Netflie\WhatsAppCloudApi\Message\Template\Component $components = null) ``` ### Parameters #### Path Parameters - **recipient** (string) - The recipient's phone number. - **template_name** (string) - The name of the template to send. - **language** (string) - The language code for the template (e.g., 'en_US'). - **components** (Component|null) - An optional Component object to define dynamic parts of the template. ``` -------------------------------- ### Send Button Reply Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a message with predefined buttons for quick replies. Requires configuring the WhatsApp Cloud API client with phone number ID and access token. ```php 'your-configured-from-phone-number-id', 'access_token' => 'your-facebook-whatsapp-application-token' ]); $rows = [ new Button('button-1', 'Yes'), new Button('button-2', 'No'), new Button('button-3', 'Not Now'), ]; $action = new ButtonAction($rows); $whatsapp_cloud_api->sendButton( '', 'Would you like to rate us on Trustpilot?', $action, 'RATE US', // Optional: Specify a header (type "text") 'Please choose an option' // Optional: Specify a footer ); ``` -------------------------------- ### Send Single Product Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Sends a single product message to a recipient, highlighting a specific product from a catalog. ```APIDOC ## Send Single Product Message ### Description Sends a single product message to a recipient, highlighting a specific product from a catalog. ### Method POST (Implied by SDK method) ### Endpoint Not explicitly defined, SDK method `sendSingleProduct` is used. ### Parameters - **destination_phone_number** (string) - Required - The recipient's phone number. - **catalog_id** (string) - Required - The ID of the catalog. - **sku_id** (string) - Required - The SKU ID of the product. - **body** (string) - Optional - The body text of the message. - **footer** (string) - Optional - The footer text for the message. ### Request Example ```php '; $sku_id = ''; $body = 'Hello! Here\'s your requested product. Thanks for shopping with us.'; $footer = 'Subject to T&C'; $whatsapp_cloud_api->sendSingleProduct( '', $catalog_id, $sku_id, $body, $footer ); ?> ``` ### Response Success response details not explicitly provided in the source. ``` -------------------------------- ### Webhook Verification Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Verifies the webhook endpoint to ensure it's correctly configured with Meta. ```APIDOC ## Webhook verification ### Description Verifies the webhook endpoint to ensure it's correctly configured with Meta. This is typically done via a GET request with specific query parameters. ### Method GET (Implied by verification process) ### Endpoint Not explicitly defined, SDK method `verify` is used. ### Parameters - **query_params** (object) - Required - The GET request query parameters. - **verify_token** (string) - Required - The verify token defined in your Meta App dashboard. ### Request Example ```php verify($_GET, ""); ?> ``` ### Response - **string** - Typically 'challenge' or an error message if verification fails. ``` -------------------------------- ### Send Basic Template Message Source: https://github.com/netflie/whatsapp-cloud-api/blob/main/README.md Send a basic template message to a WhatsApp number. The language code is optional and defaults to 'en_US'. ```php sendTemplate('34676104574', 'hello_world', 'en_US'); // If not specified, Language will be default to en_US and otherwise it will be required. ```