WebClient

无传输数据获取

             Uri uri = new Uri(allURL);
WebClient wc = new WebClient();
wc.Encoding = System.Text.Encoding.UTF8;
var str = wc.DownloadString(uri.ToString());

有传输数据获取

        var valuesout = new NameValueCollection();// 所加参数
valuesout["data"] = data;
valuesout["_aop_signature"] = _aop_signature; byte[] response;
using (var client1 = new WebClient())
{
response = client1.UploadValues("路径", valuesout);
} string str = System.Text.Encoding.UTF8.GetString(response);//解码

WebRequest

  /// <summary>
/// 发送HTTP请求
/// </summary>
/// <param name="url">请求的URL</param>
/// <param name="param">请求的参数</param>
/// <returns>请求结果</returns>
public static string request(string url, string param)
{
string strURL = url + '?' + param;
System.Net.HttpWebRequest request;
request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
request.Method = "GET";
// 添加header
request.Headers.Add("apikey", "您自己的apikey");
System.Net.HttpWebResponse response;
response = (System.Net.HttpWebResponse)request.GetResponse();
System.IO.Stream s;
s = response.GetResponseStream();
string StrDate = "";
string strValue = "";
StreamReader Reader = new StreamReader(s, Encoding.UTF8);
while ((StrDate = Reader.ReadLine()) != null)
{
strValue += StrDate + "\r\n";
}
return strValue;
}

jQuery ajax jsonp

                 $.ajax({
type: "get",
async: false,
//contentType: "application/json; charset=utf-8",
url: "http://bulabula.top/json.js",
dataType: "jsonp", //数据类型为jsonp
jsonp:"callback",
jsonpCallback:"callBackFun", //服务端用于接收callback调用的function名的参数
success: function(data) {
console.log(data);
},
error: function(a,b,c) {
console.log(a);console.log(b);
console.log(c);
}
});