{"id":14986954,"url":"https://github.com/netflie/whatsapp-cloud-api","last_synced_at":"2025-05-14T05:10:23.896Z","repository":{"id":37068412,"uuid":"495136775","full_name":"netflie/whatsapp-cloud-api","owner":"netflie","description":"The first PHP API to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform","archived":false,"fork":false,"pushed_at":"2024-12-04T16:43:23.000Z","size":245,"stargazers_count":547,"open_issues_count":10,"forks_count":201,"subscribers_count":31,"default_branch":"main","last_synced_at":"2025-05-11T21:04:47.223Z","etag":null,"topics":["php","sdk","whatsapp","whatsapp-api","whatsapp-business-api","whatsapp-cloud-api","whatsappcloudapi"],"latest_commit_sha":null,"homepage":"https://netflie.es/portfolio/whatsapp-business-cloud-api-php-sdk/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netflie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["aalbarca"]}},"created_at":"2022-05-22T17:59:30.000Z","updated_at":"2025-05-09T23:18:23.000Z","dependencies_parsed_at":"2023-02-19T10:45:35.921Z","dependency_job_id":"431b96fb-cadd-4cfc-b0c2-16d98253403e","html_url":"https://github.com/netflie/whatsapp-cloud-api","commit_stats":{"total_commits":161,"total_committers":22,"mean_commits":7.318181818181818,"dds":"0.49689440993788825","last_synced_commit":"820c2bbd4c351da45e7ee7e0f5b7957e3d3044cd"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Fwhatsapp-cloud-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Fwhatsapp-cloud-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Fwhatsapp-cloud-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Fwhatsapp-cloud-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netflie","download_url":"https://codeload.github.com/netflie/whatsapp-cloud-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076849,"owners_count":22010611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","sdk","whatsapp","whatsapp-api","whatsapp-business-api","whatsapp-cloud-api","whatsappcloudapi"],"created_at":"2024-09-24T14:13:52.129Z","updated_at":"2025-05-14T05:10:23.858Z","avatar_url":"https://github.com/netflie.png","language":"PHP","funding_links":["https://github.com/sponsors/aalbarca"],"categories":[],"sub_categories":[],"readme":"![](https://netflie.es/wp-content/uploads/2022/05/whatsapp_cloud_api_banner-1.png)\n\n\n## What It Does\nThis package makes it easy for developers to access [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api \"WhatsApp Cloud API\") service in their PHP code.\n\nThe first **1,000 conversations** each month are free from WhatsApp Cloud API. A conversation.\n\n## Getting Started\nPlease create and configure your Facebook WhatsApp application following the [\"Get Stared\"](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started) section of the official guide.\n\nMinimum requirements – To run the SDK, your system will require **PHP \u003e= 7.4** with a recent version of **CURL \u003e=7.19.4** compiled with OpenSSL and zlib.\n\n## Installation\n```composer require netflie/whatsapp-cloud-api ```\n\n## Quick Examples\n\n### Send a text message\n```php\n\u003c?php\n\n// Require the Composer autoloader.\nrequire 'vendor/autoload.php';\n\nuse Netflie\\WhatsAppCloudApi\\WhatsAppCloudApi;\n\n// Instantiate the WhatsAppCloudApi super class.\n$whatsapp_cloud_api = new WhatsAppCloudApi([\n    'from_phone_number_id' =\u003e 'your-configured-from-phone-number-id',\n    'access_token' =\u003e 'your-facebook-whatsapp-application-token',\n]);\n\n$whatsapp_cloud_api-\u003esendTextMessage('34676104574', 'Hey there! I\\'m using WhatsApp Cloud API. Visit https://www.netflie.es');\n```\n\n### Send a document\nYou can send documents in two ways: by uploading a file to the WhatsApp Cloud servers (where you will receive an identifier) or from a link to a document published on internet.\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\LinkID;\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\MediaObjectID;\n\n$document_id = '341476474779872';\n$document_name = 'whatsapp-cloud-api-from-id.pdf';\n$document_caption = 'WhastApp API Cloud Guide';\n\n// With the Media Object ID of some document upload on the WhatsApp Cloud servers\n$media_id = new MediaObjectID($document_id);\n$whatsapp_cloud_api-\u003esendDocument('34676104574', $media_id, $document_name, $document_caption);\n\n// Or\n$document_link = 'https://netflie.es/wp-content/uploads/2022/05/image.png';\n$link_id = new LinkID($document_link);\n$whatsapp_cloud_api-\u003esendDocument('34676104574', $link_id, $document_name, $document_caption);\n```\n\n### Send a template message\n```php\n\u003c?php\n\n$whatsapp_cloud_api-\u003esendTemplate('34676104574', 'hello_world', 'en_US'); // If not specified, Language will be default to en_US and otherwise it will be required.\n```\n\nYou also can build templates with parameters:\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Template\\Component;\n\n$component_header = [];\n\n$component_body = [\n    [\n        'type' =\u003e 'text',\n        'text' =\u003e '*Mr Jones*',\n    ],\n];\n\n$component_buttons = [\n    [\n        'type' =\u003e 'button',\n        'sub_type' =\u003e 'quick_reply',\n        'index' =\u003e 0,\n        'parameters' =\u003e [\n            [\n                'type' =\u003e 'text',\n                'text' =\u003e 'Yes',\n            ]\n        ]\n    ],\n    [\n        'type' =\u003e 'button',\n        'sub_type' =\u003e 'quick_reply',\n        'index' =\u003e 1,\n        'parameters' =\u003e [\n            [\n                'type' =\u003e 'text',\n                'text' =\u003e 'No',\n            ]\n        ]\n    ]\n];\n\n$components = new Component($component_header, $component_body, $component_buttons);\n$whatsapp_cloud_api-\u003esendTemplate('34676104574', 'sample_issue_resolution', 'en_US', $components); // Language is optional\n```\n\n### Send an audio message\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\LinkID;\n\n$audio_link = 'https://netflie.es/wp-content/uploads/2022/05/file_example_OOG_1MG.ogg';\n$link_id = new LinkID($audio_link);\n$whatsapp_cloud_api-\u003esendAudio('34676104574', $link_id);\n```\n\n### Send an image message\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\LinkID;\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\MediaObjectID;\n\n$link_id = new LinkID('http(s)://image-url');\n$whatsapp_cloud_api-\u003esendImage('\u003cdestination-phone-number\u003e', $link_id);\n\n//or\n\n$media_id = new MediaObjectID('\u003cimage-object-id\u003e');\n$whatsapp_cloud_api-\u003esendImage('\u003cdestination-phone-number\u003e', $media_id);\n```\n\n### Send a video message\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\LinkID;\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\MediaObjectID;\n\n$link_id = new LinkID('http(s)://video-url');\n$whatsapp_cloud_api-\u003esendVideo('\u003cdestination-phone-number\u003e', $link_id, '\u003cvideo-caption\u003e');\n\n//or\n\n$media_id = new MediaObjectID('\u003cimage-object-id\u003e');\n$whatsapp_cloud_api-\u003esendVideo('\u003cdestination-phone-number\u003e', $media_id, '\u003cvideo-caption\u003e');\n```\n\n### Send a sticker message\n\nStickers sample: https://github.com/WhatsApp/stickers\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\LinkID;\nuse Netflie\\WhatsAppCloudApi\\Message\\Media\\MediaObjectID;\n\n$link_id = new LinkID('http(s)://sticker-url');\n$whatsapp_cloud_api-\u003esendSticker('\u003cdestination-phone-number\u003e', $link_id);\n\n//or\n\n$media_id = new MediaObjectID('\u003csticker-object-id\u003e');\n$whatsapp_cloud_api-\u003esendSticker('\u003cdestination-phone-number\u003e', $media_id);\n```\n\n### Send a location message\n\n```php\n\u003c?php\n\n$whatsapp_cloud_api-\u003esendLocation('\u003cdestination-phone-number\u003e', $longitude, $latitude, $name, $address);\n```\n\n### Send a location request message\n\n```php\n\u003c?php\n\n$body = 'Let\\'s start with your pickup. You can either manually *enter an address* or *share your current location*.';\n$whatsapp_cloud_api-\u003esendLocationRequest('\u003cdestination-phone-number\u003e', $body);\n```\n\n### Send a contact message\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\Contact\\ContactName;\nuse Netflie\\WhatsAppCloudApi\\Message\\Contact\\Phone;\nuse Netflie\\WhatsAppCloudApi\\Message\\Contact\\PhoneType;\n\n$name = new ContactName('Adams', 'Smith');\n$phone = new Phone('34676204577', PhoneType::CELL());\n\n$whatsapp_cloud_api-\u003esendContact('\u003cdestination-phone-number\u003e', $name, $phone);\n```\n\n### Send a list message\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\OptionsList\\Row;\nuse Netflie\\WhatsAppCloudApi\\Message\\OptionsList\\Section;\nuse Netflie\\WhatsAppCloudApi\\Message\\OptionsList\\Action;\n\n$rows = [\n    new Row('1', '⭐️', \"Experience wasn't good enough\"),\n    new Row('2', '⭐⭐️', \"Experience could be better\"),\n    new Row('3', '⭐⭐⭐️', \"Experience was ok\"),\n    new Row('4', '⭐⭐️⭐⭐', \"Experience was good\"),\n    new Row('5', '⭐⭐️⭐⭐⭐️', \"Experience was excellent\"),\n];\n$sections = [new Section('Stars', $rows)];\n$action = new Action('Submit', $sections);\n\n$whatsapp_cloud_api-\u003esendList(\n    '\u003cdestination-phone-number\u003e',\n    'Rate your experience',\n    'Please consider rating your shopping experience in our website',\n    'Thanks for your time',\n    $action\n);\n```\n\n### Send a CTA URL message\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\Message\\CtaUrl\\TitleHeader;\n\n$header = new TitleHeader('Booking');\n\n$whatsapp_cloud_api-\u003esendCtaUrl(\n    '\u003cdestination-phone-number\u003e',\n    'See Dates',\n    'https://www.example.com',\n    $header,\n    'Tap the button below to see available dates.',\n    'Dates subject to change.',\n);\n```\n\n### Send Catalog Message\n\n```php\n\u003c?php\n\n$body = 'Hello! Thanks for your interest. Ordering is easy. Just visit our catalog and add items you\\'d like to purchase.';\n$footer = 'Best grocery deals on WhatsApp!';\n$sku_thumbnail = '\u003cproduct-sku-id\u003e'; // product sku id to use as header thumbnail\n\n$whatsapp_cloud_api-\u003esendCatalog(\n    '\u003cdestination-phone-number\u003e',\n    $body,\n    $footer, // optional\n    $sku_thumbnail // optional\n);\n```\n\n### Send a button reply message\n\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\WhatsAppCloudApi;\nuse Netflie\\WhatsAppCloudApi\\Message\\ButtonReply\\Button;\nuse Netflie\\WhatsAppCloudApi\\Message\\ButtonReply\\ButtonAction;\n\n$whatsapp_cloud_api = new WhatsAppCloudApi([\n  'from_phone_number_id' =\u003e 'your-configured-from-phone-number-id',\n  'access_token' =\u003e 'your-facebook-whatsapp-application-token' \n]);\n\n$rows = [\n    new Button('button-1', 'Yes'),\n    new Button('button-2', 'No'),\n    new Button('button-3', 'Not Now'),\n];\n$action = new ButtonAction($rows);\n\n$whatsapp_cloud_api-\u003esendButton(\n    '\u003cdestination-phone-number\u003e',\n    'Would you like to rate us on Trustpilot?',\n    $action,\n    'RATE US', // Optional: Specify a header (type \"text\")\n    'Please choose an option' // Optional: Specify a footer \n);\n```\n\n### Send Multi Product Message\n```php\n\u003c?php\n\nuse Netflie\\WhatsAppCloudApi\\WhatsAppCloudApi;\nuse Netflie\\WhatsAppCloudApi\\Message\\MultiProduct\\Row;\nuse Netflie\\WhatsAppCloudApi\\Message\\MultiProduct\\Section;\nuse Netflie\\WhatsAppCloudApi\\Message\\MultiProduct\\Action;\n\n$rows_section_1 = [\n    new Row('\u003cproduct-sku-id\u003e'),\n    new Row('\u003cproduct-sku-id\u003e'),\n    // etc\n];\n\n$rows_section_2 = [\n    new Row('\u003cproduct-sku-id\u003e'),\n    new Row('\u003cproduct-sku-id\u003e'),\n    new Row('\u003cproduct-sku-id\u003e'),\n    // etc\n];\n\n$sections = [\n    new Section('Section 1', $rows_section_1),\n    new Section('Section 2', $rows_section_2),\n];\n\n$action = new Action($sections);\n$catalog_id = '\u003ccatalog-id\u003e';\n$header = 'Grocery Collections';\n$body = 'Hello! Thanks for your interest. Here\\'s what we can offer you under our grocery collection. Thank you for shopping with us.';\n$footer = 'Subject to T\u0026C';\n\n$whatsapp_cloud_api-\u003esendMultiProduct(\n    '\u003cdestination-phone-number\u003e',\n    $catalog_id,\n    $action,\n    $header,\n    $body,\n    $footer // optional\n);\n```\n\n### Send Single Product Message\n```php\n\u003c?php\n\n$catalog_id = '\u003ccatalog-id\u003e';\n$sku_id = '\u003cproduct-sku-id\u003e';\n$body = 'Hello! Here\\'s your requested product. Thanks for shopping with us.';\n$footer = 'Subject to T\u0026C';\n\n$whatsapp_cloud_api-\u003esendSingleProduct(\n    '\u003cdestination-phone-number\u003e',\n    $catalog_id,\n    $sku_id,\n    $body, // body: optional\n    $footer // footer: optional\n);\n```\n\n### Replying messages\n\nYou can reply a previous sent message:\n\n```php\n\u003c?php\n\n$whatsapp_cloud_api\n    -\u003ereplyTo('\u003cwhatsapp-message-id-to-reply\u003e')\n    -\u003esendTextMessage(\n        '34676104574',\n        'Hey there! I\\'m using WhatsApp Cloud API. Visit https://www.netflie.es'\n    );\n```\n\n### React to a Message\n\nYou can react to a message from your conversations if you know the messageid\n\n```php\n\u003c?php\n\n$whatsapp_cloud_api-\u003esendReaction(\n        '\u003cdestination-phone-number\u003e',\n        '\u003cmessage-id-to-react-to\u003e',\n        '👍', // the emoji\n    );\n\n// Unreact to a message\n$whatsapp_cloud_api-\u003esendReaction(\n        '\u003cdestination-phone-number\u003e',\n        '\u003cmessage-id-to-unreact-to\u003e'\n    );\n\n```\n\n## Media messages\n### Upload media resources\nMedia messages accept as identifiers an Internet URL pointing to a public resource (image, video, audio, etc.). When you try to send a media message from a URL you must instantiate the `LinkID` object.\n\nYou can also upload your media resources to WhatsApp servers and you will receive a resource identifier:\n\n```php\n$response = $whatsapp_cloud_api-\u003euploadMedia('my-image.png');\n\n$media_id = new MediaObjectID($response-\u003edecodedBody()['id']);\n$whatsapp_cloud_api-\u003esendImage('\u003cdestination-phone-number\u003e', $media_id);\n\n```\n\n### Download media resources\nTo download a media resource:\n\n```php\n$response = $whatsapp_cloud_api-\u003edownloadMedia('\u003cmedia-id\u003e');\n```\n\n\n## Message Response\nWhatsAppCloudApi instance returns a Response class or a ResponseException if WhatsApp servers return an error.\n\n```php\ntry {\n    $response = $this-\u003ewhatsapp_app_cloud_api-\u003esendTextMessage(\n        '\u003cdestination-phone-number\u003e,\n        'Hey there! I\\'m using WhatsApp Cloud API. Visit https://www.netflie.es',\n        true\n    );\n} catch (\\Netflie\\WhatsAppCloudApi\\Response\\ResponseException $e) {\n    print_r($e-\u003eresponse()); // You can still check the Response returned from Meta servers\n}\n```\n\n## Webhooks\n\n### Webhook verification\nAdd your webhook in your Meta App dashboard. You need to verify your webhook:\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse Netflie\\WhatsAppCloudApi\\WebHook;\n\n// Instantiate the WhatsAppCloudApi super class.\n$webhook = new WebHook();\n\necho $webhook-\u003everify($_GET, \"\u003cthe-verify-token-defined-in-your-app-dashboard\u003e\");\n```\n\n### Webhook notifications\nWebhook is now verified, you will start receiving notifications every time your customers send messages.\n\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\ndefine('STDOUT', fopen('php://stdout', 'w'));\n\nuse Netflie\\WhatsAppCloudApi\\WebHook;\n\n\n$payload = file_get_contents('php://input');\nfwrite(STDOUT, print_r($payload, true) . \"\\n\");\n\n// Instantiate the Webhook super class.\n$webhook = new WebHook();\n\n// Read the first message\nfwrite(STDOUT, print_r($webhook-\u003eread(json_decode($payload, true)), true) . \"\\n\");\n\n//Read all messages in case Meta decided to batch them\nfwrite(STDOUT, print_r($webhook-\u003ereadAll(json_decode($payload, true)), true) . \"\\n\");\n```\n\nThe `Webhook::read` function will return a `Notification` instance. Please, [explore](https://github.com/netflie/whatsapp-cloud-api/tree/main/src/WebHook/Notification \"explore\") the different notifications availables.\n\n### Mark a message as read\nWhen you receive an incoming message from Webhooks, you can mark the message as read by changing its status to read. Messages marked as read display two blue check marks alongside their timestamp.\n\nMarking a message as read will also mark earlier messages in the conversation as read.\n\n```php\n\u003c?php\n\n$whatsapp_cloud_api-\u003emarkMessageAsRead('\u003cmessage-id\u003e');\n```\n\n### Get Business Profile\n```php\n\u003c?php\n\n$whatsapp_cloud_api-\u003ebusinessProfile('\u003cfields\u003e');\n```\n\n### Update Business Profile\n```php\n\u003c?php\n\n$whatsapp_cloud_api-\u003eupdateBusinessProfile([\n    'about' =\u003e '\u003cabout_text\u003e',\n    'email' =\u003e '\u003cemail\u003e'\n]);\n```\n\nFields list: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles\n\n## Features\n\n- Send Text Messages\n- Send Documents\n- Send Templates with parameters\n- Send Audios\n- Send Images\n- Send Videos\n- Send Stickers\n- Send Locations\n- Send Location Request\n- Send Contacts\n- Send Lists\n- Send Buttons\n- Send Multi Product Message\n- Send Single Product\n- Upload media resources to WhatsApp servers\n- Download media resources from WhatsApp servers\n- Mark messages as read\n- React to a Message\n- Get/Update Business Profile\n- Webhook verification\n- Webhook notifications\n\n## Getting Help\n- Ask a question on the [Discussions forum](https://github.com/netflie/whatsapp-cloud-api/discussions \"Discussions forum\")\n- To report bugs, please [open an issue](https://github.com/netflie/whatsapp-cloud-api/issues/new/choose \"open an issue\")\n\n## Migration to v2\n\nPlease see [UPGRADE](https://github.com/netflie/whatsapp-cloud-api/blob/main/UPGRADE.md \"UPGRADE\") for more information on how to upgrade to v2.\n\n## Changelog\n\nPlease see [CHANGELOG](https://github.com/netflie/whatsapp-cloud-api/blob/main/CHANGELOG.md \"CHANGELOG\") for more information what has changed recently.\n\n## Testing\n```php\ncomposer unit-test\n```\nYou also can run tests making real calls to the WhastApp Clou API. Please put your testing credentials on **WhatsAppCloudApiTestConfiguration** file.\n```php\ncomposer integration-test\n```\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/netflie/.github/blob/master/CONTRIBUTING.md \"CONTRIBUTING\") for details.\n\n## License\n\nThe MIT License (MIT). Please see License File for more information. Please see [License file](https://github.com/netflie/whatsapp-cloud-api/blob/main/LICENSE \"License file\") for more information.\n\n## Disclaimer\n\nThis package is not officially maintained by Facebook. WhatsApp and Facebook trademarks and logos are the property of Meta Platforms, Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetflie%2Fwhatsapp-cloud-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetflie%2Fwhatsapp-cloud-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetflie%2Fwhatsapp-cloud-api/lists"}