Php Plivo租了一个不适合我的Api
它会给我错误信息Php Plivo租了一个不适合我的Api,php,plivo,Php,Plivo,它会给我错误信息 require 'vendor/autoload.php'; use Plivo\RestAPI; $auth_id = "My AUTH_ID"; $auth_token = "My AUTH_TOKEN"; $p = new RestAPI($auth_id, $auth_token); $params = array( 'number' => '12512077502' # Phone number to buy ); $response
require 'vendor/autoload.php';
use Plivo\RestAPI;
$auth_id = "My AUTH_ID";
$auth_token = "My AUTH_TOKEN";
$p = new RestAPI($auth_id, $auth_token);
$params = array(
'number' => '12512077502' # Phone number to buy
);
$response = $p->get_number($params);
print_r ($response);
请看这里我使用的是Python plivo模块,遇到了同样的问题 来自Plivo支持:“使用新API:” 我发现plivo模块在租用电话号码时使用了错误的URL。我的工作是在没有助手库的情况下进行调用。下面是Python代码,但它可能会帮助您了解如何做
Array (
[status] => 404
[response] => Array (
[api_id] => 0b6214ee-aec4-11e5-ae4f-22000ac69a0d
[error] => not found
) )
更新:上述内容可能根本没有必要。我刚从Plivo支持部门得到最新消息。新方法名为
buy\u phone\u number()
,而不是get\u number()
。这为我解决了问题。我假设PHP库也是如此。您似乎使用了python助手库中的错误函数(get_number)。正确的方法是使用PhoneNumber API的“购买电话号码”函数
参考-
import requests
params = {
'number' : phone_number # Phone number to buy
}
host = 'https://api.plivo.com/v1/Account/%s/PhoneNumber/%s/' % \
(account_sid, phone_number)
r = requests.post(host, timeout=5, json=params, auth=(account_sid, auth_token))
assert r.status_code == 201, 'r.status_code=%s' % `r.status_code`