关于API接口GB2312的问题

[复制链接]
查看11 | 回复4 | 2021-1-27 05:57:47 | 显示全部楼层 |阅读模式
&dataType=json"
SetRetrieval=Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
Retrieval.open"GET",subUrlxiaoqu,False,"",""
Retrieval.SetRequestHeader"Content-Type","text/htmlcharset=gb2312"
Retrieval.send()
ResponseTxtxiaoqu=Retrieval.responseText
SetRetrieval=Nothing
endif
%>

">


这是我写的一个API接口。对方也是GB2312的。从IE里直接打URL是测试通过的。但是我用GET方法就会反馈错误。这是什么原因
我下面的测试AHERF是可以取得正确的返回值的
分 -->
回复

使用道具 举报

千问 | 2021-1-27 05:57:47 | 显示全部楼层
试试Server.UrlEncode
"http://data.esf.sina.com.cn/Apisinahouse/getlikecommtodis?district="&Server.UrlEncode("宝山")&"&comm....
回复

使用道具 举报

千问 | 2021-1-27 05:57:47 | 显示全部楼层
对方也是用GBK接收的.所以转成UTF8会有问题
回复

使用道具 举报

千问 | 2021-1-27 05:57:47 | 显示全部楼层
直接浏览器访问http://data.esf.sina.com.cn/Apisinahouse/getlikecommtodis?district=宝山&communityname=呼玛五村&agentId=5147603320&companyId=1333&signature=87a5e15f522fe89861bedf39c04f26b0&dataType=json
返回的是{"code":"-2","result":"\u6570\u5b57\u7b7e\u540d\u9a8c\u8bc1\u5931\u8d25"}
其中中文部分为:数字签名验证失败

回复

使用道具 举报

千问 | 2021-1-27 05:57:47 | 显示全部楼层
">asdf
解码函数
?@[\]^`{|}~%"
fori=1tolen(enStr)
c=Mid(enStr,i,1)
ifc="%"then
v=eval("&h"+Mid(enStr,i+1,2))
ifinStr(strSpecial,chr(v))>0then
deStr=deStr&chr(v)
i=i+2
else
v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
deStr=deStr&chr(v)
i=i+5
endif
else
ifc="+"then
deStr=deStr&""
else
deStr=deStr&c
endif
endif
next
URLDecode=deStr
Endfunction
response.WriteURLDecode(request.QueryString("action"))
%>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行