【问题标题】:Plivo Rent a number Api not Working for mePlivo Rent a number Api 不适合我
【发布时间】:2016-02-17 05:31:29
【问题描述】:
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);

它会给我错误信息

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

【问题讨论】:

    标签: php plivo


    【解决方案1】:

    您似乎使用了 python 帮助程序库中的错误函数 (get_number)。正确的是使用 PhoneNumber API 的“buy_phone_number”函数。

    参考 - https://github.com/plivo/plivo-python/blob/master/plivo.py#L175

    【讨论】:

      【解决方案2】:

      我在使用 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 库也是如此。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-11-23
        • 1970-01-01
        • 1970-01-01
        • 2022-12-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多