I want to send a message via whatsapp using Twilio API for WhatsApp in PHP. my code doesn't give an error but the message isn't being received in the target mobile phone..
here's my code:
// For live API
$this->sid = 'MY_TWILIO_SID';
$this->token = 'MY_TOKEN';
$this->from_number = '+178678xxx';
$client = new Client($this->sid, $this->token);
$to = '+628123456789';
$msg = 'Some greeting message';
// Use the client to do fun stuff like send text messages!
$response = $client->messages
->create(
// the number you'd like to send the message to
"whatsapp:".$to,
array(
// A Twilio phone number you purchased at twilio.com/console
'from' => "whatsapp:".$this->from_number,
// the body of the text message you'd like to send
'body' => $msg
)
);
echo '<pre>';
print_r($response);
echo '</pre>';
the result was a Twilio MessageInstance Object like this:
Twilio\Rest\Api\V2010\Account\MessageInstance Object
(
[_media:protected] =>
[_feedback:protected] =>
[version:protected] => Twilio\Rest\Api\V2010 Object
...
[solution:protected] => Array
(
[accountSid] => xxxxx
[sid] => xxxxx
)
)
note: I've contacted the Twilio cust.service and 4 days ago she informed me that my sender number (+1786...) has been registered and can send and receive messages via whatsapp.