2015-12-30 48 views
3
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); 

它会给我错误消息Plivo租的API不是为我工作

Array ( 
    [status] => 404 
    [response] => Array ( 
      [api_id] => 0b6214ee-aec4-11e5-ae4f-22000ac69a0d 
      [error] => not found 
)) 

看到这里https://www.plivo.com/docs/getting-started/phone-number-api/#rent-a-number

回答

0

我使用Python plivo模块和有同样的问题。

从Plivo支持:“使用新的API:https://www.plivo.com/docs/api/number/phonenumber/#buy-number

我发现了plivo模块租用电话号码时使用了错误的URL。我的工作是拨打而不需要帮助程序库。以下是Python代码,但它可能会帮助您知道该怎么做。

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` 

更新:上面可能没有必要毕竟。我刚从Plivo支持中获得了一个更新。新的方法名称是buy_phone_number()而不是get_number()。这解决了我的问题。我假设PHP库也是如此。