2

我正在开发与 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没有任何问题。

4

1 回答 1

6

来自 Twilio 的 Ricky 在这里。

看起来您在我们的文档中发现了一个错误。您可以像这样访问“基本价格”和“当前价格”:

$priceData->outbound_call_price->base_price;
$priceData->outbound_call_price->current_price;
于 2015-10-29T21:01:54.913 回答