Hello there, i have a problem. I want to create a new extension from my own php project. i created a service that will work with freepbx. My problem is the extension type. I have to create it as sip, but it keeps created as virtual…
Yes you’re right, it should change “SIP/$userName” but name always same extension in my project. I wanted to make sure extension is type of int because $_POST always returns string. Sorry this is not my solution.
This is PHP code, so No, PHP returns a value that can be interpreted in one of several ways. Variable type in PHP is fluid and converts automatically to whatever the lvalue is required to be. To be further pedantic, $_POST always returns an associative array. Sorry - CIS teacher mode popped up there.
Either way - have you looked at the code for “Bulk Handler”? It does all of this and is open source. You should be able to snag that code and reinterpret it to manage your code.
Also, with FreePBX 15, there’s going to be an API, so that’s going to deprecate this code.
first of all thank you for correcting me on this. I’m a junior developer who has switched to php for the last 1 month.
I looked but did not understand much. do I need to create and import csv file in my service code every time. And after creating sip extension, I need to add it to the current “paging and intercom”. Is this possible?
I couldn’t find enough information about rest api in wiki
I’m not suggesting you drop your current project or code. The source code for the Bulk Handler module is available from GitHub.com (in the FreePBX Git Repo) so you can easily snag the code that already does this for the current system and “extend” it to do everything you need to do.
If all you needed to do was create extensions, the easy way is to create a CSV file with the fields filled in and feed it to the Bulk Handler module. Since you need to do more than that, your approach (assuming you lift the code from GitHub) will probably work just fine.
The REST API (which is available now in several versions of FreePBX) is different than the system API that’s coming out with the release of FreePBX 15. It’s not surprising that you can’t find a lot of documentation yet - I get the impression that everyone at Sangoma is playing “Rock - Paper - Scissors” to see who is going to get stuck documenting this cool new feature.