patrickmathews Posted October 29, 2014 Share Posted October 29, 2014 (edited) I recently converted my business to an ip-pbx that has lots of capabilites. Among them is a feature I would like to use called http_notify. It sends a post to a url with parameters such as caller id number, caller id name etc.. I need to write a simple program to accept these parameters and write them to a csv file along with a date/time stamp. This seems like a super easy, short piece of code to come up with and as a noob I was hoping to write this myself. I have found a few examples where the post is for a form but I can't find any examples where the data is coming in as part of the url. This is the description of the feature on the phone system site: HTTP Notify Sends notifications to a remote web server through a URL. This allows allows an event in a Jive Core PBX to trigger an action on a remote system. Simply enter a URL in the node, and that URL will be hit with an HTTP POST as calls 'pass through'. Multiple variables are available and all variables are also included in the post body. URL Defines the URL to be used (limit of 255 characters). Next Node Connects nodes together to create a call flow. Drag and drop on the next node in the dial plan. Sample Use Cases 1. Trigger a remote application to generate a "screen pop" notification. 2. Trigger an email/SMS message in real-time. 3. Allow supplemental real-time call logging. Below is an example URL that passes the Caller ID number and the Dialed Number to a remote web server located at www.example.com: http://www.example.com/call_notification.php?caller={CALLER_ID_NUMBER}&dialed={DIALED_NUMBER} In the example above, variables in curly brackets { } are replaced with their actual value. For example, if a call to 801-555-0123 was placed from 909-555-0111, the URL would become: http://www.example.com/call_notification.php?caller=9095550111&dialed=8015550123 The following variables are available to use in URL variables. Variable In POST Body Description PBX_ID Y The ID of the PBX DIALED_NUMBER Y The number the caller dialed DNIS N Same as DIALED_NUMBER CALLER_ID_NUMBER Y The caller's number CNUM N Same as CALLER_ID_NUMBER CALLER_ID_NAME Y The caller's name (if available) CNAM N Same as CALLER_ID_NAME CALL_ID Y A unique ID for the call EVENT Y Always "URLNotifyNode.Notify" Does anyone have an example of something that accepts parameters and writes them to a file? Edited October 29, 2014 by patrickmathews Quote Link to comment Share on other sites More sharing options...
winningdave Posted October 30, 2014 Share Posted October 30, 2014 This should get your basic parameters into a file for you. <?php$req_dump = print_r($_REQUEST, TRUE);$fp = fopen('request.log', 'a');fwrite($fp, $req_dump);fclose($fp); ?> You should then be able to write the parameters to a csv file: <?php $string = $_REQUEST['PBX_ID'].",".$_REQUEST['DIALED_NUMBER'].",".$_REQUEST['CALLER_ID_NUMBER'].",".date("Y-m-d H:i:s")."\r\n"; file_put_contents('jive.csv',$string,FILE_APPEND|LOCK_EX); ?> You may need to encapsulate the data in double quotes if you hit a snag with special characters Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 30, 2014 Share Posted October 30, 2014 I think you should learn more and take this output to a real db rather than a csv. Then you have some REAL data that you can then do anything with later on. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.