这是在开发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;
}
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
http://autoprajs.ru/13027.html
https://marvelvsdc.faith/wiki/User:CourtneyMedford
https://elearnportal.science/wiki/Mp3bit.pw
http://army.clanfm.ru/viewtopic.php?f=2&t=35503
https://klimovsk.bbeasy.ru/viewtopic.php?id=8102#p19992
https://wiki.evil-admin.com/index.php?title=User:BobbieBernier2
Рождественские Песни – Rosemary Clooney – Merry Christmas All скачать песню в mp3 и слушать онлайн бесплатно
Рождественские Песни – Rosemary Clooney – Merry Christmas All
https://beregifiguru.ru/%D0%A4%D0%BE%D1%80%D1%83%D0%BC/%D0%A2%D0%B5%D0%BC%D0%B0/%D0%B8%D1%81%D1%82%D0%BE%D1%80%D0%B8%D1%8F-%D0%B6%D0%B0%D0%BD%D1%80%D0%B0-chillout/6586
http://dianov.bget.ru/forum/thread53036.html#1207526
http://dianov.bget.ru/forum/thread52340.html#1183449
https://www.click-boutique.ru/forum/?PAGE_NAME=profile_view&UID=39730
https://radioluch.ru/club/?page=user_forum_message&user_id=14266&topic_id=6097&message_id=11057#message11057
Dubvision/handed – Are You Listening скачать песню в mp3 и слушать онлайн бесплатно
Dubvision/handed – Are You Listening
http://mafiaclans.ru/viewtopic.php?f=31&t=3768
https://woman.build2.ru/viewtopic.php?id=12025#p39243
http://psylab.flybb.ru/viewtopic.php?f=95&t=4813
http://futurepedia.coloradofuturefest.com/index.php?title=User:MillardIhg
Дима Данилов Feat. Иван Zeldi – Пойду С Тобой Ко Дну скачать песню в mp3 и слушать онлайн бесплатно
Дима Данилов Feat. Иван Zeldi – Пойду С Тобой Ко Дну
https://samaramed.ru/forum/health/topic_39949.html
https://zarabotaem.bbmy.ru/viewtopic.php?id=3135#p5021
https://menwiki.men/wiki/Mp3bit.pw_2
http://tr.clanfm.ru/viewtopic.php?f=33&t=8904
https://profbuh.forumkz.ru/viewtopic.php?id=6411#p10660
Рождественские Песни – Rosemary Clooney – Merry Christmas All скачать песню в mp3 и слушать онлайн бесплатно
Рождественские Песни – Rosemary Clooney – Merry Christmas All
https://wartburg.clanbb.ru/viewtopic.php?id=1933#p78466
https://cashboom.ru/forum/user/11453/
https://koveclub.ru/index.php?/gallery/image/30-%D1%8D%D0%B2%D0%BE%D0%BB%D1%8E%D1%86%D0%B8%D1%8F-%D0%B7%D0%B2%D1%83%D0%BA%D0%B0-%D0%BF%D0%BE%D0%BF%D1%83%D0%BB%D1%8F%D1%80%D0%BD%D1%8B%D0%B5-%D0%BC%D1%83%D0%B7%D1%8B%D0%BA%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B5-%D0%B0%D0%BB%D1%8C%D0%B1%D0%BE%D0%BC%D1%8B-%D1%81-%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%B0-90-%D1%85/&context=new
https://wiki.beingesports.com/index.php?title=User:GlennFergusson6
https://profbuh.forumkz.ru/viewtopic.php?id=6411#p10660
Orxan Masalli – Atash Sevimli Inadkar Qadin 2019 (Dj Tebriz) скачать песню в mp3 и слушать онлайн бесплатно
Orxan Masalli – Atash Sevimli Inadkar Qadin 2019 (Dj Tebriz)