请求示例:
{AppSecret}:签约后技术人员会提供
{url}:yinsihao.1oc.cn
{returnurl} 需要URL编码,通话记录结果会POST至此URL。
{mobphone} 被叫手机号(被叫)
{cph} 车牌号(建议填写,走运营商挪车专用线路「更稳定」,不填写走普通隐私号线路)(强烈建议填写)
{bindtime} 绑定有效期,单位分钟(最大不超过20)(选填)
CURL
curl -i -k --post --include 'http://{url}/?module=yinsihao&file=apibind&action=getprivacynumber&mobphone={mobphone}&cph={cph}&bindtime={bindtime}&returnurl={returnurl}' -H 'Authorization:{AppSecret}'PHP
$host="http://{url}";
$path="/";
$method="POST";
$appsecret="{AppSecret}";
$headers=array();
array_push($headers,"Authorization:".$appsecret);
array_push($headers,"Content-Length: 0");
$querys="module=yinsihao&file=apibind&action=getprivacynumber&mobphone={mobphone}&cph={cph}&bindtime={bindtime}&returnurl={returnurl}";
$bodys="";
$url=$host.$path."?".$querys;
$curl=curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST,$method);
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_FAILONERROR,false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HEADER,true);
if(1==strpos("$".$host,"https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
}
var_dump(curl_exec($curl));JAVA
public static void main(String[] args) {
String host = "http://{url}";
String path = "/";
String method = "GET";
String appsecret = "{AppSecret}";
Mapheaders = new HashMap();
headers.put("Authorization",appsecret);
Mapquerys = new HashMap();
querys.put("module", "yinsihao");
querys.put("file", "apibind");
querys.put("action", "getprivacynumber");
querys.put("mobphone", "{mobphone}");
querys.put("cph", "{cph}");
querys.put("bindtime", "{bindtime}");
querys.put("returnurl", "{returnurl}");//通话记录回调地址
try {
/**
* 重要提示如下:
* HttpUtils请从
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
* 下载
*
* 相应的依赖请参照
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
*/
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
System.out.println(response.toString());
//获取response的body
//System.out.println(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
e.printStackTrace();
}
}Python
import urllib, urllib2, sys
import ssl
host = 'http://{url}'
path = '/'
method = 'POST'
appsecret = "{AppSecret}";
querys = 'module=yinsihao&file=apibind&action=getprivacynumber&mobphone={mobphone}&cph={cph}&bindtime={bindtime}&returnurl={returnurl}'
bodys = {}
url = host + path + '?' + querys
request = urllib2.Request(url)
request.add_header('Authorization',appsecret)
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib2.urlopen(request, context=ctx)
content = response.read()
if (content):
print(content)失败响应
{
"code": 400, //指返回结果码,并非http状态码
"msg": "域名校验失败",
}成功响应
{
"code": 200,
"msg": "ok",
"data": {
"xmobphone": "17305150036",//隐私号
"sbid": "17223184122084",//唯一id号
"starttime": 1722318412,//号码绑定开始时间
"endtime": 1722318532,//号码绑定结束时间
}
}通话记录POST至returnurl地址,数据如下:
{
'sbid'=> ''
'sb_id'=> ''//同一记录,sb_id是一样的
'xmobphone' => ''//隐私号
'bmobphone' => ''//主叫号码
'mobphone' => ''//被叫号码
'thsc' => ''//通话时长(秒)
'mid' => ''//唯一ID,查询通话录音转文字需要。
'startime' => ''//X号码绑定时间(时间戳)
'endtime' => ''//X号码有效期结束时间(时间戳)
'call_starttime' => ''//呼叫开始时间(时间戳)
'call_endtime' => ''//呼叫结束时间(时间戳)
'status' => ''//通话状态(具体查看状态码)
'recordurl' => ''//录音地址
'bj_province' => ''//被叫号码所在省份
'bj_city' => ''//被叫号码所在城市
'bj_sp' => ''//被叫号码所在运营商
'zj_province' => ''//主叫号码所在省份
'zj_city' => ''//主叫号码所在城市
'zj_sp' => ''//主叫号码所在运营商
'op_answer_time' => ''//被叫接听时间(时间戳)
}客户端收到结果后返回:
success


