排列五开奖号码走势图|排列五开奖公告
首頁 > 免費電話教程 > 傻瓜式搭建自己的sip通用回撥

201405月24

傻瓜式搭建自己的sip通用回撥

作者:admin 7 Comments 發表評論

本文轉載自凌霄論壇,為一技術文章,基本能看懂,但是不知道為什么CURL要設置那些項目,SSY也不知道是什么玩意,懂的可以加我討論!原作者的代碼不知道是不是他自己寫的!請自行測試,過段時間我也測試個!

【準備】

ssy賬號一個,支持curl的php空間一個

【開始】

第一步:用ssy賬號登錄SSY控制面板

第二步:點擊【Setting】->【Click here to show your API key】查看并負責你的API Key

第三步:將下面的代碼復制保存為【sip.php】

第四步:將ssy賬號名稱及API Key配置到【sip.php】并將【sip.php】上傳到你的網站空間根目錄(推薦)

第五步:訪問http://你的域名/sip.php?firstrun=true初始化程序,如我的是http://sovi.cc/sip.php?firstrun=true

第六步:現在就可以配置你的sip賬號到你的sip回撥平臺(http://你的域名/sip.php)上打回撥電話了!

代碼如下:

<?php
header(“Content-Type: text/html;charset=utf-8”);
//配置信息

$apiKey= “4029ad2f40e99bcc53e964b842fec99999999614bfb57c2770f6b83d7e8fde575482acaf6eadb374f999ebbf59897b8f”;//你的ssy帳號的apiKey
$account=”myaccount”;//你的ssy帳號

$user=$_REQUEST[“user”];
$pass=$_REQUEST[“pass”];
$server=$_REQUEST[“server”];

function GetProviderID(){
global $apiKey;
$url=”https://www.sipsorcery.com/rest/v0.1/provisioning.svc/sipprovider/get”;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIE, “apikey=”.$apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
$result=json_decode($result,true);

return $result[‘Result’][0][‘ID’];
}
function UpdateProvider($ID){
global $apiKey;
global $account;
global $user;
global $pass;
global $server;

$url=”https://www.sipsorcery.com/rest/v0.1/provisioning.svc/sipprovider/update”;

$body=json_encode(array(“ID”=>$ID,
“ProviderName”=>”myProvider”,
“ProviderUsername”=>$user,
“ProviderPassword”=>$pass,
“ProviderServer”=>$server,
“ProviderAuthUsername”=>null,
“ProviderOutboundProxy”=>null,
“ProviderType”=>”SIP”,
“ProviderFrom”=>null,
“CustomHeaders”=>null,
“RegisterContact”=>”sip:{$account}@sipsorcery.com”,
“RegisterExpiry”=>3600,
“RegisterServer”=>null,
“RegisterRealm”=>null,
“RegisterEnabled”=>true,
“GVCallbackNumber”=>null,
“GVCallbackPattern”=>null,
“GVCallbackType”=>null)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array(“Content-Type: application/json; charset=utf-8”));
curl_setopt($ch, CURLOPT_COOKIE, “apikey=”.$apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$result = curl_exec($ch);
curl_close($ch);
$result=json_decode($result,true);

return $result[‘Success’];
}
function GetDialPlanID(){
global $apiKey;
$url=”https://www.sipsorcery.com/rest/v0.1/provisioning.svc/dialplan/get”;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIE, “apikey=”.$apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
$result=json_decode($result,true);

return $result[‘Result’][0][‘ID’];
}
function UpdateDialPlan($ID){
global $apiKey;
$url=”https://www.sipsorcery.com/rest/v0.1/provisioning.svc/dialplan/update”;

$body=json_encode(array(“ID”=>$ID,
“DialPlanName”=>”webcallback”,
“TraceEmailAddress”=>null,
“DialPlanScript”=>”str=req.URI.User.to_s\r\ncaller = str.split(‘,’)\r\nsys.Callback(\”#{caller[0]}@myProvider\”,\”#{caller[1]}@myProvider\”)”,
“ScriptTypeDescription”=>”Ruby”,
“AcceptNonInvite”=>False)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array(“Content-Type: application/json; charset=utf-8”));
curl_setopt($ch, CURLOPT_COOKIE, “apikey=”.$apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$result = curl_exec($ch);
curl_close($ch);
$result=json_decode($result,true);

return $result[‘Success’];
}
if($_GET[“firstrun”]==”true”){
if(UpdateDialPlan(GetDialPlanID())){
die(“程序初始化完成,歡迎<a href='”.$_SERVER[‘SCRIPT_NAME’].”‘>使用</a>!”);
}else{
die(“程序初始化失敗,請檢查apiKey!”);
}
}
?>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/>
<title>Sovi通用SIP回撥平臺</title>
</head>
<body>
<center><h2>SIP通用回撥平臺</h2>
<form action=”sip.php” method=”post”>
<p>SIP:<input name=”server” type=”text” value=”<?php echo $_REQUEST[“server”];?>”></p>
<p>用戶:<input name=”user” type=”text” value=”<?php echo $_REQUEST[“user”];?>”></p>
<p>密碼:<input name=”pass” type=”text” value=”<?php echo $_REQUEST[“pass”];?>”></p>
<p>主叫:<input name=”caller” type=”text” value=”<?php echo $_REQUEST[“caller”];?>”></p>
<p>被叫:<input name=”called” type=”text” value=”<?php echo $_REQUEST[“called”];?>”></p>
<input name=”sovi” type=”submit” value=”Call”>
</form>
<?php
if($_POST[‘sovi’]==”Call”){
if(UpdateProvider(GetProviderID($ID))){
echo “SIP信息已提交<br/>”;
}else{
die(“SIP信息提交失敗<br/>”);
}
$url=’https://www.sipsorcery.com/callmanager.svc/webcallback?user=’.$account.’&number=’.$_REQUEST[“caller”].’,’.$_REQUEST[“called”];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result=curl_exec($ch);
curl_close($ch);
if(strstr($result,”Web call was successfully initiated”)!=False){
echo “呼叫請求已提交,請等待來電”;
}else{
echo “發起呼叫失敗!”;
}
}
?>
<hr/>
Code By:創建者名字<br/>
QQ:創建者QQ號碼<br/>
<?php echo date(‘Y-m-d H:i:s’,time());?>
</center>
</body>
</html>

代碼也可以直接下載:http://pan.baidu.com/share/link?shareid=1803133734&uk=907001332

推薦閱讀相關文章:免費電話教程

本文地址:http://www.c7hk.com/dajian-sip.html
版權所有 © 轉載時必須以鏈接形式注明作者和原始出處!

7 Responses to “傻瓜式搭建自己的sip通用回撥”

  1. #1 寒冰 回復 | 引用 Post:2014-05-24 15:27

    學習了,不過貌似ssy不開放免費注冊了啊

  2. #2 軒轅銀河 回復 | 引用 Post:2014-05-25 08:35

    還是直接用軟件來的直接

  3. #3 蒙洛 回復 | 引用 Post:2014-05-26 09:48

    不知道在哪注冊ssy?沒有搜索到啊。求指教

    • #4 admin 回復 | 引用 Post:2014-05-26 13:07

      我也沒有玩過SSY,聽說現在不能注冊了,你可以去淘寶搜索看看有沒有賣這個賬號的!

  4. #5 GG 回復 | 引用 Post:2014-05-28 07:31

    我幾年前注冊了SSY賬號,一直沒用過,昨天登陸網站,賬號竟然還有效。

  5. #6 GG 回復 | 引用 Post:2014-05-28 07:45

    sipsorcery.com,就是這個網站,當時搞了一下,覺得這個東西好復雜,就沒有搞了,現在覺得國外的網站比國內好,你的賬號四五年不使用都不會注銷。本貼的原作者搞了個無限5分鐘和無限10分鐘打電話,也想試試,但是找不到資源,有知道的朋友嗎?

    • #7 admin 回復 | 引用 Post:2014-05-28 08:23

      國外的網站確實比較好,穩定性強很多。不過現在國內的免費回撥比較多,穩定性不怎么樣。

發表評論

排列五开奖号码走势图