87,989
社区成员
发帖
与我相关
我的任务
分享 $(function () {
$.getJSON("http://api.map.baidu.com/ag/coord/convert?callback=?", {
from: 2,
to: 4,
x: 116.254615,
y: 29.814476
}, function (data) {
alert(data.x);
});
}); //设置代理
WebProxy proxy = new WebProxy("proxy.cccil.com",8000);
proxy.Credentials = new NetworkCredential("km35609", "qwe1234!", "proxy.cccil.com");
//访问baidu方法
WebRequest wr = WebRequest.Create("http://api.map.baidu.com/ag/coord/convert?from=2&to=4&x=116.254615&y=29.814476");
wr.Proxy = proxy;
WebResponse wp = wr.GetResponse();
Stream s = wp.GetResponseStream();
StreamReader sr = new StreamReader(s);
string str = sr.ReadToEnd();
Response.Write(str);
sr.Dispose();
s.Dispose();
Server Error in '/WebMapinfo' Application.
--------------------------------------------------------------------------------
The remote server returned an error: (407) Proxy Authentication Required.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
Source Error:
Line 20:
Line 21: WebRequest wr = WebRequest.Create("http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x=116.254615&y=29.814476");
Line 22: WebResponse wp = wr.GetResponse();
Line 23: Stream s = wp.GetResponseStream();
Line 24: StreamReader sr = new StreamReader(s);
WebRequest wr = WebRequest.Create("http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x=116.254615&y=29.814476");
WebResponse wp = wr.GetResponse();
Stream s = wp.GetResponseStream();
StreamReader sr = new StreamReader(s);
string str = sr.ReadToEnd();
Response.Write(str);
sr.Dispose();
s.Dispose();http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x=116.254615&y=29.814476var str = '{"error":0,"x":"MTE2LjI2MTA5OTEyMjE=","y":"MjkuODIwNTYwODc0ODQ2"}';
var obj = eval('('+ str +')');
alert(obj.error)
alert(obj.x)
alert(obj.y)