Giter Club home page Giter Club logo

Comments (4)

benedmunds avatar benedmunds commented on May 20, 2024

Yes you can, the endpoint is documented here: https://www.twilio.com/docs/api/rest/incoming-phone-numbers#instance-delete

from codeigniter-twilio.

mosio avatar mosio commented on May 20, 2024

You should be able to do that using:

$this->twilio->account->incoming_phone_numbers->delete($sid);

For example (not tested live, but something like this should work):

try {
  $twilio_phone_number = '+15555555555';  
  $nums = $this->twilio->account->incoming_phone_numbers->getIterator(0, 1, array("PhoneNumber" => $twilio_phone_number));
  foreach ($nums as $n) {
    $this->client->account->incoming_phone_numbers->delete($n->sid);
  }
}
catch (Exception $e) {
}

from codeigniter-twilio.

 avatar commented on May 20, 2024

Thank you both for responding but I have tried that endpoint as follows and it doesn't work, it tells me method not supportd. Here is my code:

$url = '/' . $this->api_version . '/Accounts/' . $this->account_sid . '/IncomingPhoneNumbers.json';

$data = array(
'PhoneNumber' => $phone_number,
);

return $this->_twilio->request($url, 'DELETE', $data);

from codeigniter-twilio.

mosio avatar mosio commented on May 20, 2024

Delete is not supported on your URL: https://www.twilio.com/docs/api/rest/incoming-phone-numbers#list-delete

You need to call it specifying the incoming phone number's SID in the url: https://www.twilio.com/docs/api/rest/incoming-phone-numbers#instance

My code should work to retrieve this info if you only know the phone number you want to delete, but it does require two api calls to do the work.

from codeigniter-twilio.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.