[Python] How can I get a list of my phone numbers filtered by country in Twilio?

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024.

  1. Stack

    Stack Membro Participativo

    I'm using Flask and Python with Twilio to make calls. I need to make calls to different countries, so I have a list of numbers from different countries. I want to use a phone number of the same country I'm making the call to.

    I know I can get a list of my numbers with:

    phone_numbers = client.incoming_phone_numbers.list(page_size=1000)

    for phone in phone_numbers:
    print("phone_number: ", phone.phone_number)


    Is there a way to filter the phone_numbers list so that I only get numbers from a specific country? Something like: client.incoming_phone_numbers.list(country='US', page_size=1000).

    My last resort is to check the beginning of the phone number string with a list of country codes, but it's not ideal.

    Continue reading...

Compartilhe esta Página