Twilio获取所有帐号

时间:2016-03-22 17:02:23

标签: python api twilio

我有一个帐号,其中包含超过100个数字,我想获得所有这些数字的列表。我的问题是list()函数最多给出了50,并且似乎没有任何方法可以覆盖它。有没有办法通过UI或API来导出我购买的所有号码?

由于

2 个答案:

答案 0 :(得分:0)

执行此操作的新方法是

from twilio.rest import Client

account_sid = "{{ sid }}"
auth_token  = "{{ token }}"
client = Client(account_sid, auth_token)

incoming_phone_numbers = client.incoming_phone_numbers.list(limit=20)

for record in incoming_phone_numbers:
    print record.phone_number

答案 1 :(得分:-1)

Twilio开发者传道者在这里。

你可以在这里做几件事。首先,Twilio允许你request more of a list of resources by increasing the PageSize parameter。默认'Email' => [ 'gmail' => [ 'transport' => 'gmail', 'from' => 'myemail@gmail.com' ] ], 为50,但您可以要求最多1000个。

在Python中,您可以这样做:

    $mail
        ->to($email)
        ->profile('gmail')
        ->subject($this->subject)
        ->emailFormat('html')
        ->template('welcome')
        ->viewVars([
            $name=>$name,
            $code=>$code
        ]);

如果您的号码超过1000个,那么您仍然可以浏览资源列表。 Python helper library实际上提供了一个迭代器,它将继续请求页面,直到您到达列表的末尾。您可以看到example of how to use the iterator in the Python helper library documentation或以下:

PageSize

让我知道这是否有帮助。