[asterisk-app-dev] How do I get variables from ARI Asterisk?

Oscar scriviaoscar at yahoo.it
Fri Feb 20 02:03:11 CST 2015


thanks for the advice, and yes I'm confused, I'm newbie in asterisk.
I understand over mistake, the script correct is:

$ch = curl_init();curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_URL,"http://192.168.56.12:8088/ari/channels");curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);curl_setopt($ch, CURLOPT_USERPWD, "asterisk:asterisk");curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));curl_setopt($ch,CURLOPT_POST, true);
$variables = array("channelId"=>$data->channel->id);$queryParameter = array("endpoint" => "SIP/201", "app" => "call-center", "variables" => $variables);curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($queryParameter));

that is, I used both extension/context/priority and app, I remove "extension/context/priority" and the args's setted :-)
in what contest I use the "variables"? and over all, an example in order to use them?
in document I read:
Body parameter   
   - variables: containers - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }


but I don't understand how and when use it... :-(where are the body parameter?
thanks a lot
_______________________________________________________________________
Oscar OXY

      Da: Krandon <krandon.bruse at gmail.com>
 A: Oscar <scriviaoscar at yahoo.it>; Asterisk Application Development discussion <asterisk-app-dev at lists.digium.com> 
 Inviato: Venerdì 20 Febbraio 2015 4:19
 Oggetto: Re: [asterisk-app-dev] How do I get variables from ARI Asterisk?
   
 I don’t get the channel variables in the StasisStart, you only get the arguments for StasisStart.
Just grab the variable once you have the channel ID:
$this->pest->get("/ari/channels/" . $channelID . "/variable?variable=“ . $variableName);
I think you may be a little confused, however, as you are trying to save the channelId as a variable when you initiate the call. If you want to change the channelId of the call when you initiate it, simply change your $queryParameters to include “channelId” => “blahblah” then you can just reference channel blahblah (or enumerated blahblah) in the future. 
-- KB

 

On Thursday, February 19, 2015 at 12:49 PM, Oscar wrote: 
 How do I get variables from ARI Asterisk?

I've done:
$ch = curl_init();   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   curl_setopt($ch, CURLOPT_URL,"http://192.168.56.12:8088/ari/channels");   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);   curl_setopt($ch, CURLOPT_USERPWD, "asterisk:asterisk");   curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));      curl_setopt($ch,CURLOPT_POST, true);
$variables = array("channelId"=>$data->channel->id);   $queryParameter = array("endpoint" => "SIP/201", "extension" => "201", "context" => "oscar", "priority" => "1", "app" => "call-center", "variables" => $variables);   curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($queryParameter));
 $result=curl_exec($ch);
(where $data->channel->id is datas from "generate an outbound call")
the calling work fine, but in websocket/app "call-center" I haven't got the args, why?
I receive:
{  "type": "StasisStart",  "timestamp": "2015-02-19T19:28:25.069+0100",  "args": [],  "channel": {    "id": "asterisk_oscar-1424370499.121",    "name": "SIP/201-0000003d",    "state": "Up",    "caller": {      "name": "",      "number": ""    },    "connected": {      "name": "",      "number": ""    },    "accountcode": "",    "dialplan": {      "context": "oscar",      "exten": "",      "priority": 1    },    "creationtime": "2015-02-19T19:28:19.527+0100"  },  "application": "call-center"}

What do I mistake?thanks _______________________________________________________________________
Oscar OXY
_______________________________________________asterisk-app-dev mailing listasterisk-app-dev at lists.digium.comhttp://lists.digium.com/cgi-bin/mailman/listinfo/asterisk-app-dev 
  
 

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-app-dev/attachments/20150220/1b8ad983/attachment.html>


More information about the asterisk-app-dev mailing list