Reputation: 5123
I created free account on twilio and I get this generated phone no
+1 (201) 345-7453
when I tried to use this phone # in the code
$sms = $client->account->sms_messages->create("+1 (201) 345-7453", "myphone # here", "Jenny please?! I love you <3", array());
echo $sms->sid;
Fatal error: Uncaught exception 'Services_Twilio_RestException' with message 'The From phone number +12013457453 is not a valid, SMS-capable inbound phone number or short code for your account
Upvotes: 0
Views: 1298
Reputation: 51
The "From" property becomes "from" when you call the create() method because of
abstract class Services_Twilio_InstanceResource extends Services_Twilio_Resource {
...
$decamelizedParams = $this->client->createData($this->uri, $params);
$this->updateAttributes($decamelizedParams);
https://github.com/twilio/twilio-php/blob/master/Services/Twilio/InstanceResource.php#L31
The "SMS Message" resource has been deprecated by Twilio so don't expect a fix. I recommend you just move over to the now "Messages" resource (https://twilio-php.readthedocs.org/en/latest/usage/rest/messages.html#sending-a-message).
It's as easy as...
$response = $client->account->messages->create([
'To' => '+10000000000',
'From' => '+10000000000',
'Body' => $msg,
'MediaUrl' => 'https://some.com/image.jpg'
]);
echo $response;
Upvotes: 3