致命错误:带有消息的未捕获异常'Services_Twilio_RestException'

时间:2015-06-01 14:16:48

标签: twilio twilio-php

我在twilio上创建了免费帐户,我收到了这个生成的手机没有

+1 (201) 345-7453

当我尝试在代码

中使用此手机#时
$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

1 个答案:

答案 0 :(得分:2)

&#34; From&#34;财产成为&#34;来自&#34;当你因为

而调用create()方法时
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

&#34;短信&#34;资源已被Twilio弃用,所以不要期待修复。我建议你转到现在的#34;消息&#34;资源(https://twilio-php.readthedocs.org/en/latest/usage/rest/messages.html#sending-a-message)。

它就像......一样简单。

$response = $client->account->messages->create([
    'To'       => '+10000000000',
    'From'     => '+10000000000',
    'Body'     => $msg,
    'MediaUrl' => 'https://some.com/image.jpg'
]);

echo $response;