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
486 stars 177 forks source link

template message counld't be send ? #80

Closed murugapandiyan closed 1 year ago

murugapandiyan commented 1 year ago

i try to send whatsapp template like header "documents" body

"string text"

not working your code.

kindly let me know how to send message thorugh whatsapp template media with body content.

aalbarca commented 1 year ago

Please provide an example of your code.

Thanks.

murugapandiyan commented 1 year ago

//$whatsapp_cloud_api->sendTextMessage('91'.$mobile_no, 'Hi '.$name.', // //You are login successfully on Damooga Foundation. If you cannot perform login now, kindly information to @.*** // //Thanks // //Support Team //Damooga Foundation');

$name_1 = 'muruga' ;

$donation_amount = '150';

$payment_ref_no = '154785' ;

$mobile_no_1 = '91'.'9944191122';

//$component_header = [];

use Netflie\WhatsAppCloudApi\Message\Template\Component;

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

$component_header = [        [ 'type' => 'document', 'document' => 'https://dfngo.org/vendor/pan_card.pdf', ],               ];

$component_body = [ [ 'type' => 'text', 'text' => $name_1, ],       [ 'type' => 'text', 'text' => $donation_amount, ],       [ 'type' => 'text', 'text' => $payment_ref_no, ], ];

$document_id = '341476474779872'; $document_name = 'pan_card.pdf'; $document_caption = 'WhastApp API Cloud Guide';

$components = new Component($component_header, $component_body); $whatsapp_cloud_api->sendTemplate($mobile_no_1, 'sample_flight_confirmation', 'en_US', $components); // Language is optional

Thanks & Ragrds

muruga

Message ID: @.***>

aalbarca commented 1 year ago

Hi @murugapandiyan

You're building wrong the header component for the document url. Please check the official guide: https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates#interactive

Best regards.