netflie / whatsapp-cloud-api

The first PHP API to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform
https://netflie.es/portfolio/whatsapp-business-cloud-api-php-sdk/
MIT License
449 stars 163 forks source link

Facing issue with Undefined variable: whatsapp_cloud_api #50

Closed maddymathan closed 1 year ago

maddymathan commented 1 year ago

Notice: Undefined variable: whatsapp_cloud_api in E:\xampp_7.4.6\xampp\htdocs\whatsapp_api\wa_cloud_api\index.php on line 14

Fatal error: Uncaught Error: Call to a member function sendDocument() on null in E:\xampp_7.4.6\xampp\htdocs\whatsapp_api\wa_cloud_api\index.php:14 Stack trace: #0 {main} thrown in E:\xampp_7.4.6\xampp\htdocs\whatsapp_api\wa_cloud_api\index.php on line 14

aalbarca commented 1 year ago

Hi @maddymathan show your code please. Thanks.

maddymathan commented 1 year ago

require_once 'vendor/autoload.php';

use Netflie\WhatsAppCloudApi\Message\Media\LinkID; use Netflie\WhatsAppCloudApi\Message\Media\MediaObjectID;

$document_id = 'EAAGSBUkK7tsBALDFPuZB29O6k7bFk53AsEp2KW1yNIBsxeqs8FuWfQsfUtk3b0llw2WsZBkou1NZB7Kr4mW3j2LIqws5WGGM3FqJX9IFXBVNdmhHOaGIgv8MyVDbJFqj9kL10OuDXOKZA7W9zCJN94jfynQq5drxlAyj4QsnkUMqYQbmPByL'; $document_name = 'ATM001_08-10-2022.pdf'; $document_caption = 'WhastApp API Cloud Guide';

// With the Media Object ID of some document upload on the WhatsApp Cloud servers $media_id = new MediaObjectID($document_id); $whatsapp_cloud_api->sendDocument('918248175266', $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('918248175266', $link_id, $document_name, $document_caption);

maddymathan commented 1 year ago

i have updated the code

aalbarca commented 1 year ago

The variable $whatsapp-cloud-api is not instantiated in your code.

maddymathan commented 1 year ago

//whatsapp-cloud-api

I don't understand whatsapp-cloud-api was not available in your sample code. You have using as whatsapp_cloud_api but still is not working brother.