这是在开发QQ访客加速软件写的核心操作功能类,现在贡献出来,并且也为以后的开发提供示例!以下是核心协议及功能代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
namespace QzoneSpeed
{
class Qzone
{
private string uin;
private string skey;
private string pskey;
private string cookie;
public Qzone() {
}
public Qzone(string uin, string skey, string pskey)
{
this.uin = uin;
this.skey = skey;
this.pskey = pskey;
this.cookie = this.cookies();
}
//获取cookie
private string cookies()
{
string res;
if (this.pskey == "")
{
res = "pt2gguin=o" + this.uin + "; uin=o0" + this.uin + "; skey=" + this.skey + ";";
}
else
{
res = "pt2gguin=o" + this.uin + "; uin=o" + this.uin + "; skey=" + this.skey + ";p_skey=" + this.pskey + "; p_uin=o" + this.uin + ";";
}
return res.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
}
//获取gtk
public string GetGTK(string sKey)
{
if (skey=="")
{
return "";
}
var hash = 5381;
for (int i = 0, len = sKey.Length; i < len; ++i)
{
hash += (hash << 5) + sKey[i];
}
return (hash & 0x7fffffff).ToString();
}
//设置header
public static void SetHeaderValue(WebHeaderCollection header, string name, string value)
{
var property = typeof(WebHeaderCollection).GetProperty("InnerCollection",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (property != null)
{
var collection = property.GetValue(header, null) as NameValueCollection;
collection[name] = value;
}
}
//发送HTTP请求
public string http(string url, string post = "", string referer = "1", string cookie = "0", string header = "0", string ua = "0", string nobaody = "0")
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
if (!header.Equals("0"))
{
string[] headers = header.Split('|');
for (int i = 0; i < headers.Length; i++)
{
SetHeaderValue(request.Headers, headers[i].Split(':')[0], headers[i].Split(':')[1]);
}
}
if (!post.Equals(""))
{
request.Method = "POST";
}
else
{
request.Method = "GET";
request.Proxy = null;
request.KeepAlive = false;
request.AutomaticDecompression = DecompressionMethods.GZip;
}
if (!referer.Equals("1"))
{
request.Referer = referer;
}
else
{
request.Referer = "http://h5.qzone.qq.com/mqzone/index";
}
if (ua.Equals("0"))
{
request.UserAgent = "Mozilla/5.0 (Linux; U; Android 4.4.1; zh-cn) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.5 Mobile Safari/533.1";
}
else
{
request.UserAgent = ua;
}
if (!cookie.Equals("0"))
{
request.Headers.Add("Cookie", cookie);
}
if (!post.Equals(""))
{
byte[] data = Encoding.UTF8.GetBytes(post);
request.ContentLength = data.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
}
request.Accept = "application/json";
SetHeaderValue(request.Headers, "Accept-Encoding", "gzip,deflate,sdch");
SetHeaderValue(request.Headers, "Accept-Language", "zh-CN,zh;q=0.8");
SetHeaderValue(request.Headers, "Connection", "close");
HttpWebResponse myResponse = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();
return content;
}
catch (Exception ex)
{
return ex.Message;
}
}
//获取字符串间内容
public string GetText(string t, string k, string j)
{
try //异常捕捉
{
var kn = t.IndexOf(k, StringComparison.Ordinal) + k.Length;
var jn = t.IndexOf(j, kn, StringComparison.Ordinal);
return t.Substring(kn, jn - kn);
}
catch
{
return "fail"; //返回错误
}
}
//访客加速操作(mobile)
public bool Visitor(string qq)
{
string url = "https://h5.qzone.qq.com/webapp/json/friendSetting/reportSpaceVisitor?qzonetoken=qzonetoken&g_tk=" + this.GetGTK(this.pskey) + "&uin=" + qq + "&visitUin=" + this.uin;
string post = "g_tk=" + this.GetGTK(this.pskey) + "&uin=" + qq + "&visitUin=" + this.uin;
string res = this.http(url, post, "1", this.cookie);
return res == "{\"ret\":0,\"msg\":\"\",\"data\":{\"retCode\":0}}";
}
//获取今日访客数
public string TodayVisitorCount(string qq)
{
string url = "https://mobile.qzone.qq.com/mqz_get_visitor?g_tk=" + this.GetGTK(this.skey) + "&res_mode=0&res_uin=" + qq + "&offset=0&count=1&page=1&format=json&t=1562141624588";
string res = this.http(url, "", "1", this.cookie);
res = GetText(res, ",\"todaycount\":", ",\"totalcount\"");
string nums = res == "fail" ? "0" : res;
return nums;
}
//获取qzonetoken
public string GetQzoneToken()
{
string url = "https://h5.qzone.qq.com/mqzone/index";
string ua = "Mozilla/5.0 (Linux; U; Android 4.4.1; zh-cn) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.5 Mobile Safari/533.1";
string res = this.http(url, "", "1", this.cookie, "0", ua);
res = GetText(res, "(function(){ try{return \"", "\";}");
return res;
}
}
}
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Your article helped me a lot, is there any more related content? Thanks!
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Your article helped me a lot, is there any more related content? Thanks!
Can you be more specific about the content of your enticle? After reading it, I still have some doubts. Hope you can help me.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://accounts.binance.com/ka-GE/register?ref=RQUR4BEO
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://www.binance.com/de-CH/register?ref=UM6SMJM3
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Choose BWER for trusted weighbridge systems in Iraq, offering customized solutions to optimize your industrial operations and ensure precise weight measurement every time.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Your article helped me a lot, is there any more related content? Thanks!
Tatar, Татарин – Hollywood (Rendow Prod.) скачать бесплатно песню в mp3
Tatar, Татарин – Hollywood (Rendow Prod.) скачать бесплатно песню в mp3
Bad Boys Blue – You’re A Woman (Long Version) скачать песню бесплатно в mp3 и слушать онлайн
Bad Boys Blue – You’re A Woman (Long Version) скачать песню бесплатно в mp3 и слушать онлайн
Ch1Kne71 – Happy Days скачать в mp3 и слушать онлайн бесплатно
Ch1Kne71 – Happy Days скачать в mp3 и слушать онлайн бесплатно
Клубная Музыка – Инструментальная Красивая Музыка – Инструменталка – Биение Двух Сердец скачать бесплатно песню и слушать онлайн в mp3
Клубная Музыка – Инструментальная Красивая Музыка – Инструменталка – Биение Двух Сердец скачать бесплатно песню и слушать онлайн в mp3
5Утра, Оксана Почепа (Акула) – Позвони скачать песню в mp3 и слушать онлайн бесплатно
5Утра, Оксана Почепа (Акула) – Позвони скачать песню в mp3 и слушать онлайн бесплатно
Polamav – Вівторок скачать песню в mp3 и слушать онлайн
Polamav – Вівторок скачать песню в mp3 и слушать онлайн
Скачать песню Инструментальная Музыка – Микаэл Таривердиев – Дороги бесплатно в mp3
Скачать песню Инструментальная Музыка – Микаэл Таривердиев – Дороги бесплатно в mp3
Скачать песню Украинские Хиты – Lazanovskyi I Ridnyi & Olha Taborovska – Під Дощем бесплатно в mp3
Скачать песню Украинские Хиты – Lazanovskyi I Ridnyi & Olha Taborovska – Під Дощем бесплатно в mp3
Баста Feat. Полина Гагарина – И Сказал Мне Ангел Чуть-Чуть Продержись. Я Завтра Подарю Тебе Новую Жизнь скачать песню бесплатно в mp3 и слушать онлайн
Баста Feat. Полина Гагарина – И Сказал Мне Ангел Чуть-Чуть Продержись. Я Завтра Подарю Тебе Новую Жизнь скачать песню бесплатно в mp3 и слушать онлайн