3 Star 5 Fork 4

W-Kinlon/WithMe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
JsonServer.cs 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
lumache 提交于 2020-12-21 08:54 . '增加添加好友、刷新列表功能'
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace QQ2020
{
class JsonServer
{
public string getJson(string url)
{
try
{
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //加上这一句
// 创建一个HTTP请求
HttpWebRequest request = (System.Net.HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader myreader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string json = myreader.ReadToEnd();
myreader.Close();
return json;
}
catch (System.Net.WebException)
{
MessageBox.Show("出现网络连接问题");
return null;
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/W-Kinlon/WithMe.git
git@gitee.com:W-Kinlon/WithMe.git
W-Kinlon
WithMe
WithMe
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385