我正在开发与 Twilio 交互的基于 Silex 的 Web 应用程序
我正在尝试使用 twilio-php 从 Twilio 检索定价数据,以获取特定电话号码的出站呼叫,但遇到了意外错误。
我的代码的相关部分是:
$client = new Pricing_Services_Twilio($accountSid, $authToken);
$priceData = $client->voiceNumbers->get($number);
$twigArgs = array(
'number' => $priceData->number,
'country' => $priceData->country,
'isoCountry' => $priceData->iso_country,
'priceUnit' => $priceData->price_unit,
'outboundBasePrice' => $priceData->outbound_call_price->call_base_price,
'outboundCurrentPrice' => $priceData->outbound_call_price->call_current_price,
'inboundBasePrice' => $priceData->inbound_call_price->call_base_price,
'inboundCurrentPrice' =>$priceData->inbound_call_price->call_current_price
);
这似乎与文档中的代码示例一致,但我不断收到以下异常(修改行号以匹配代码片段中的正确行):
index.php 第 9 行中的 ContextErrorException:注意:未定义属性:stdClass::$call_base_price
我究竟做错了什么?
注意:我知道这$number
是正确的,因为我能够检索$priceData->number
, $priceData->country
, $priceData->iso_country
, 并且$priceData->price_unit
没有任何问题。