抗击新冠,紧急求救,PB调用API获取手机号所在地
很多患者来源时并不说自己时武汉的,直到确诊才承认,近期一直导致几十名医生护士被隔离。为提醒同事对武汉患者重点关注,想做一个查手机号归属的接口。
http://mobsec-dianhua.baidu.com/dianhua_api/open/location?tel=15375284321
这个地址可以调通,但是我用Pb+HTTP方式调用提示
<html>
<head>
<title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Forbidden</p>
<p>The server understood the request, but is refusing to fulfill it</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
调用方法
String ls_ret
Integer li_ret
Long ll_len
Blob lbob_data
String ls_header,gs_url,resultdata
long gl_port
string ls_result
integer li_rc
string ls_url
gs_url = "http://mobsec-dianhua.baidu.com/dianhua_api/open/location?"
gl_port=80
inet linet_main
n_cst_internet luo_data // internetresult的实例
linet_main = CREATE inet
luo_data = CREATE n_cst_internet
//创建ole对象
OleObject ioo_com
ioo_com = Create OleObject
li_ret = ioo_com.ConnectToNewObject("PB115.n_unf8togbk")
If li_ret <> 0 Then
Destroy ioo_com
End if
String as_data,as_Err
as_data = "tel=" +'15375284208'
//as_data += "s01" + "&"
//as_data += "ACCESS_TOKEN=" + as_text
li_rc = GetContextService('internet',linet_main)
if li_rc<>1 then
as_Err='创建Internet服务失败'
End IF
//messagebox('GetContextService',string(li_rc))
If li_rc = 1 Then
//lbob_data = ioo_com.uf_gbktoutf8(as_data) //Blob(as_data)
lbob_data = Blob(as_data,EncodingUTF8!)
ll_len = Len(lbob_data)
//每个头key和value之间用冒号分隔,每对头之间空格分隔,头信息之后两个换行
ls_header = "Content-Type:application/x-www-form-urlencoded~n"
ls_header += "Content-Length:" + String(ll_len) + "~n~n"
li_rc = linet_main.PostURL(gs_url, lbob_data,ls_header,gl_port,luo_data)
//messagebox('PostURL',string(li_rc))
If li_ret <> 1 Then
ls_ret = "-1"
//Goto Process_end
End If
ls_ret = luo_data.is_data
End If
String ls_ret1
//ls_ret1 = ioo_com.uf_utf8togbk(luo_data.iblob_data)
//mle_1.Text = luo_data.is_data
if li_rc <1 then messagebox('发生错误',string(li_rc))
SetPointer(Arrow!)
//messagebox('',string(luo_data.is_data))
//messagebox('',string(li_rc))
string ls_text
long ll_return
resultdata = luo_data.is_data
ll_return=pos(resultdata,':')
ls_text=right(resultdata,len(resultdata)-ll_return -1)
ll_return=pos(ls_text,'"')
ls_text=left(ls_text,ll_return -1)
//mle_1.text=ls_text
Destroy ioo_com
//Process_end:
Destroy luo_data
Destroy linet_main
//mle_1.Text = mle_1.Text + '~r~n' + ls_ret
return 0
直接run网页呢,就提示下载josn
跪求解决。