【发布时间】:2024-05-29 14:50:02
【问题描述】:
我是 PHP 和 twillio 的新手。我正在尝试获取我的子帐户的所有类型使用信息。基本上我想将此信息存储在我的谷歌表中并需要此值
我能够获取我所有的子帐户 SID,如下所示
<?php
require_once 'vendor/autoload.php';
use Twilio\Rest\Client;
$sid = "my main account sid";
$token = "my token";
$twilio = new Client($sid, $token);
$accounts = $twilio->api->v2010->accounts
->read([], 20);
$items = array();
foreach ($accounts as $record) {
$items[] = $record->sid;
}
print_r($items);
?>
这很好。我可以在 forsearch 中循环我的所有子帐户以获取使用。对于 Fetch 用法,我关注 this guide
代码如下
<?php
require_once 'vendor/autoload.php';
use Twilio\Rest\Client;
$sid = "my main account";
$token = "my token";
$client = new Client($sid, $token);
$records = $client->usage->records->read(
array(
"category" => "sms-outbound",
"startDate" => "2021-02-01",
"endDate" => "2021-02-28"
)
);
// Loop over the list of records and echo a property for each one
foreach ($records as $record) {
echo $record->price;
}
?>
目前我正在获取主帐户的费用。
我不知道如何获得我在上图中提到的不同类型使用的子帐户的费用。我不知道我是否遵循正确的 API 指南来实现我的目标。让我知道这里是否有人可以指导我或举个例子。
非常感谢!
【问题讨论】:
标签: php twilio twilio-php