php - 无法将数字从子账户移动到主账户 (Twilio)
问题描述
我正在使用 Twilio PHP 帮助程序库。
我有几个存储在数据库中的子帐户凭据。每个子帐户通常有几个与之关联的拨出呼叫者 ID。
我使用每个子帐户的凭据来获取传出CallerIds。
从返回的数据中,我获取子账户 SID (AC) 和数字 SID (PN)。
我按照文档进行操作,每次尝试使用子账户中的数字更新主账户时都会收到错误消息。
捕获异常:[HTTP 404] 无法更新记录:未找到请求的资源 /2010-04-01/Accounts/ACxxxxxxxxxxxxxx/IncomingPhoneNumbers/PNxxxxxxxx.json
我检查了帐户 sids 和 number sids,它们是正确的。
知道我在哪里出错了吗?
这是我在 foreach 中进行的尝试,它为每个子帐户提供凭据。
try
{
$client = new Client($sid, $token); //subaccount sid and token from not shown foreach
$caller_ids = $client->outgoingCallerIds->read();
foreach ($caller_ids as $caller_id)
{
$phone_number = $caller_id->phoneNumber;
$friendly_name = $caller_id->friendlyName;
$number_sid = $caller_id->sid;
$account_sid = $caller_id->accountSid;
$incoming_phone_number = $master_account->incomingPhoneNumbers("$number_sid")
->update(
array("accountSid" => "$account_sid")
);
}
}
解决方案
Twilio 开发人员布道者在这里。
我认为这里的问题是您使用主帐户 sid 来引用位于子帐户中的号码,从而得到 404。相反,您应该从主帐户的帐户列表中选择子帐户,并使用该子帐户对象转接时参考号码。
例如:
$subaccount = $master_account->accounts($subaccount_sid);
$incoming_phone_number = $subaccount->incomingPhoneNumbers($number_sid)
->update(
array("accountSid" => $master_account->sid)
);
让我知道这是否有帮助。
推荐阅读
- php - 从 localhost 调用 Google API
- javascript - 标签之间的 CSS 样式空间
- php - 在 Windows 7 上安装 PEAR
- angular - 如何为动态添加的新输入行设置 ngModel 角度 4+(mat-table)
- ansible - Ansible 拆分返回多个索引
- excel - 单击事件不适用于以编程方式/动态创建的选项按钮
- android - 只选择一个复选框;回收站视图;科特林
- flutter - 颤振医生 - 系统找不到指定的路径[不是重复的]
- python - 有什么方法可以在不写入本地磁盘的情况下将 xlsxwriter 生成的文件发送到 azure 数据湖?
- python - pyqt如何获得以前的无花果管理器