如下图所示 ,是我使用的第三方呼叫平台,第三方平台会提供一个使用文档,说的比较全的。

例子一:对接来电弹屏的接口,需要写一个方法接收post过来的数据,把要使用的数据存储成文件(ps:存储方式根据自己使用的情况)

例子二:对呼叫平台坐席状态的操作,下图是项目中常用的几个操作

下图是写一个分机示忙的代码

在function文件里写一个公共请求的post提交方法,用于请求第三方接口使用,包含请求的路径、请求参数

function get_callpostsubm($url, $data = '') {
$post = '';
$row = parse_url($url);
$host = $row['host'];
$port = 80;
$file = $row['path'];
while (list($k, $v) = each($data)) {
$post .= rawurlencode($k) . "=" . rawurlencode($v) . "&"; //转URL标准码
}
$post = substr($post, 0, -1);
$len = strlen($post);
$fp = @fsockopen($host, $port, $errno, $errstr, 10);
if (!$fp) {
return "$errstr ($errno)\n";
} else {
$receive = '';
$out = "POST $file HTTP/1.0\r\n";
$out .= "Host: $host\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Connection: Close\r\n";
$out .= "Content-Length: $len\r\n\r\n";
$out .= $post;
fwrite($fp, $out);
while (!feof($fp)) {
$receive .= fgets($fp, 128);
}
fclose($fp);
$receive = explode("\r\n\r\n", $receive);
//dump($receive);
unset($receive[0]);
return implode("", $receive);
}
}
最后一句: 技术无价,不喜勿喷。
