Comments (4)
Yes you can, the endpoint is documented here: https://www.twilio.com/docs/api/rest/incoming-phone-numbers#instance-delete
from codeigniter-twilio.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codeigniter-twilio.