kevin-l
9/23/2016 - 6:42 AM

Asterisk Click2Call using PHP

Asterisk Click2Call using PHP

<?php

$from = $_GET[from];
$to = $_GET[to];
$fromext = $_GET[fromext];


 $socket = fsockopen("localhost","5038", $errno, $errstr, $timeout);
 fputs($socket, "Action: Login\r\n");
 fputs($socket, "UserName: USERNAME\r\n");
 fputs($socket, "Secret: PASSWORD\r\n\r\n");
  $wrets=fgets($socket,128);

   fputs($socket, "Action: Originate\r\n" );
   fputs($socket, "Channel: SIP/$from\r\n" );
   fputs($socket, "Exten: $to\r\n" );
   fputs($socket, "Callerid: $fromext\r\n" );
   fputs($socket, "Context: default\r\n" );
   fputs($socket, "Priority: 1\r\n" );
   fputs($socket, "Async: yes\r\n\r\n" );

   $wrets=fgets($socket,128);
sleep(3);
?>