{"id":137,"date":"2016-06-03T18:49:39","date_gmt":"2016-06-03T18:49:39","guid":{"rendered":"http:\/\/symbioticindia.in\/docu\/?p=137"},"modified":"2016-06-03T18:49:39","modified_gmt":"2016-06-03T18:49:39","slug":"click-to-dial-or-php-api-to-dial-from-asterisk","status":"publish","type":"post","link":"http:\/\/symbioticindia.in\/docu\/2016\/06\/03\/click-to-dial-or-php-api-to-dial-from-asterisk\/","title":{"rendered":"Click to Dial or php API to dial from asterisk"},"content":{"rendered":"<h1><\/h1>\n<p>PHP script for click to dial or API to dial from asterisk via http<\/p>\n<p>source : \u00a0<a href=\"http:\/\/www.elastix.org\/component\/kunena\/3-help\/13300-click-2-call-using-ami\/index.php?option=com_kunena&amp;divid=92&amp;defaultindex=1\">Elastix forum<\/a><\/p>\n<p>copy the below code to a file (call.php) \u00a0to the webdirectory.<\/p>\n<p>executes as \u00a0: \u00a0http:\/\/ipaddress\/call.php??exten=SIP\/100&amp;number=9999999999<\/p>\n<p>&lt;?php<\/p>\n<p>#ip address that asterisk is on.<br \/>\n$strHost = &#8220;127.0.0.1&#8221;;<br \/>\n$strUser = &#8220;admin&#8221;;#specify the asterisk manager username you want to login with<br \/>\n$strSecret = &#8220;elastix456&#8221;;#specify the password for the above user<br \/>\n#specify the channel (extension) you want to receive the call requests with<br \/>\n#e.g. SIP\/XXX, IAX2\/XXXX, ZAP\/XXXX, etc<br \/>\n# $strChannel = &#8220;SIP\/100&#8221;;<br \/>\n$strChannel = $_REQUEST[&#8216;exten&#8217;];<br \/>\n$strContext = &#8220;from-internal&#8221;;<br \/>\n#specify the amount of time you want to try calling the specified channel before hangin up<br \/>\n$strWaitTime = &#8220;30&#8221;;<br \/>\n#specify the priority you wish to place on making this call<br \/>\n$strPriority = &#8220;1&#8221;;<br \/>\n#specify the maximum amount of retries<br \/>\n$strMaxRetry = &#8220;2&#8221;;<br \/>\n$number=strtolower($_REQUEST[&#8216;number&#8217;]);<br \/>\n$pos=strpos ($number,&#8221;local&#8221;);<br \/>\nif ($number == null) :<br \/>\nexit() ;<br \/>\nendif ;<br \/>\nif ($pos===false) :<br \/>\n$errno=0 ;<br \/>\n$errstr=0 ;<br \/>\n$strCallerId = &#8220;Web Call $number&#8221;;<br \/>\n$oSocket = fsockopen (&#8220;localhost&#8221;, 5038, &amp;$errno, &amp;$errstr, 20);<br \/>\nif (!$oSocket) {<br \/>\necho &#8220;$errstr ($errno)&lt;br&gt;\\n&#8221;;<br \/>\n} else {<br \/>\nfputs($oSocket, &#8220;Action: login\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Events: off\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Username: $strUser\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Secret: $strSecret\\r\\n\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Action: originate\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Channel: $strChannel\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;WaitTime: $strWaitTime\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;CallerId: $strCallerId\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Exten: $number\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Context: $strContext\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Priority: $strPriority\\r\\n\\r\\n&#8221;);<br \/>\nfputs($oSocket, &#8220;Action: Logoff\\r\\n\\r\\n&#8221;);<br \/>\nsleep(2);<br \/>\nfclose($oSocket);<br \/>\n}<br \/>\necho &#8220;Extension $strChannel should be calling $number.&#8221; ;<br \/>\nelse :<br \/>\nexit() ;<br \/>\nendif ;<br \/>\n?&gt;<br \/>\nUsing this script for click to dial number in mozilla firefox.<\/p>\n<p>1. Install the Telify \u00a0addon to the mozilla<\/p>\n<p>2. then configure it as shown in below picture<\/p>\n<ol start=\"3\">\n<li>used protocal- Custom URL<\/li>\n<li>Custom URL &#8211;\u00a0https:\/\/192.168.1.2\/call.php?exten=222&amp;number=$0<\/li>\n<li>apply or ok<\/li>\n<\/ol>\n<p>once done , any numbers in the webpage or mail \u00a0will be highlighted fro click to dial.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP script for click to dial or API to dial from asterisk via http source : \u00a0Elastix forum copy the below code to a file (call.php) \u00a0to the webdirectory. executes as \u00a0: \u00a0http:\/\/ipaddress\/call.php??exten=SIP\/100&amp;number=9999999999 &lt;?php #ip address that asterisk is on. $strHost = &#8220;127.0.0.1&#8221;; $strUser = &#8220;admin&#8221;;#specify the asterisk manager username you want to login with ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"http:\/\/symbioticindia.in\/docu\/2016\/06\/03\/click-to-dial-or-php-api-to-dial-from-asterisk\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-137","post","type-post","status-publish","format-standard","hentry","category-asterisk"],"_links":{"self":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":1,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":138,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/137\/revisions\/138"}],"wp:attachment":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}