关于API接口GB2312的问题

zywandy 2014-12-26 03:55:45
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
</head>

<%



subUrlxiaoqu = "http://data.esf.sina.com.cn/Apisinahouse/getlikecommtodis?district=宝山&communityname=呼玛五村&agentId=5147603320&companyId=1333&signature=87a5e15f522fe89861bedf39c04f26b0&dataType=json> &dataType=json"
Set Retrieval = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")

Retrieval.open "GET", subUrlxiaoqu, False, "", ""
Retrieval.SetRequestHeader "Content-Type","text/html charset=gb2312"
Retrieval.send()
ResponseTxtxiaoqu = Retrieval.responseText
Set Retrieval = Nothing
end if
%>
<body>
<a href="<%=subUrlxiaoqu%>"><%=ResponseTxtxiaoqu %></a>
</body>
</html>

这是我写的一个API接口。对方也是GB2312的。从IE里直接打URL是测试通过的。但是我用GET方法就会反馈错误。这是什么原因

我下面的测试A HERF是可以取得正确的返回值的
...全文
259 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdn_aspnet 2014-12-29
  • 打赏
  • 举报
回复
<a href="1.asp?action=<%=server.urlencode("你好")%>">asdf</a> 解码函数 <% Function URLDecode(enStr) dim deStr,strSpecial dim c,i,v deStr="" strSpecial="!""#$%&'()*+,.-_/:;<=>?@[\]^`{|}~%" for i=1 to len(enStr) c=Mid(enStr,i,1) if c="%" then v=eval("&h"+Mid(enStr,i+1,2)) if inStr(strSpecial,chr(v))>0 then 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 end if else if c="+" then deStr=deStr&" " else deStr=deStr&c end if end if next URLDecode=deStr End function response.Write URLDecode(request.QueryString("action")) %>
xuzuning 2014-12-29
  • 打赏
  • 举报
回复
直接浏览器访问 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"} 其中中文部分为:数字签名验证失败
zywandy 2014-12-29
  • 打赏
  • 举报
回复
对方也是用GBK接收的.所以转成UTF8会有问题
孟子E章 2014-12-28
  • 打赏
  • 举报
回复
试试Server.UrlEncode "http://data.esf.sina.com.cn/Apisinahouse/getlikecommtodis?district=" & Server.UrlEncode("宝山") & "&comm....

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧