Jump to content

Simple program help needed


patrickmathews

Recommended Posts

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 targetNode.png 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:

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:

The following variables are available to use in URL variables.

Variable In POST Body Description

PBX_ID The ID of the PBX

DIALED_NUMBER The number the caller dialed

DNIS Same as DIALED_NUMBER

CALLER_ID_NUMBER The caller's number

CNUM Same as CALLER_ID_NUMBER

CALLER_ID_NAME The caller's name (if available)

CNAM Same as CALLER_ID_NAME

CALL_ID A unique ID for the call

EVENT Always "URLNotifyNode.Notify"

 

Does anyone have an example of something that accepts parameters and writes them to a file?

Edited by patrickmathews
Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.