Step-by-step to do WEBQQ robot-(iv) (Get Friends List and group list)

Source: Internet
Author: User

x

This article is mainly:获取好友列表,群列表

I will try to be as detailed as I can to share some of the experiences that may have been mastered or not known to you.

For everyone to read, the article style is no longer complicated, according to the content to take fixed color

The overall progress is probably 65%The full range is expected to have these steps, of course some of the steps may be merged:
    • Verification Code
    • First time Login
    • Second time landing
    • Stay online and receive messages
    • Get a list of friends and groups
    • Send Message
    • Become intelligent (*?∀?*)
Get Friends 1-Get the hash algorithm of QQ friends
        P = function (b, j) {for            (var a = j + "Password Error", i = "", E = [];;)                if (i.length <= a.length) {                    if (i + = b, i.length = = a.length) break;                } else {                    i = i.slice (0, a.length); 
   
    break                } for            (var c = 0; c < i.length; C + +) E[c] = I.charcodeat (c) ^ a.charcodeat (c);            A = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "B", "C", "D", "E", "F"];            i = "";            for (c = 0; c < e.length; C + +) i + = A[e[c] >> 4 & [], i + = A[e[c] & [];            return I        }
   

2 parameters passed in: QQ号码 ,ptwebqq(文章2中从cookie中拿到)

Get Friends 2-Request
    • Address:http://s.web2.qq.com/api/get_user_friends2
    • Refererhttp://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1
    • Post string:string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", this.VfWebQQ, this.Hash);
Get Friends 3-Return and analysis

The return JSON object consists of two parts:, retcode result The former indicates whether the request is successful or not, we mainly look at result, which contains these things:

    1. categories, classification, that is, your QQ friends group, index can be considered as the primary key of the grouping table , sort sorting, name the alias of the group. "My Friends" group by default is index:0
    2. Friends Friends, flag indicating the default avatar serial number, after the same does not mention, uin is through the full text of the parameters, is the Web page closed before the browser client's unique identity , corresponding to the categories above group information
    3. Info Stores Friends ' information--nicknames nick , uin corresponding unique identifiers
    4. marknames Note name, also uin corresponding to a unique identifier, corresponding to the name of the markname note, here to say, if there is no note, here is not displayed
    5. vipinfo, VIP information, useless
I set up a class to deserialize it
Class Jsonfriendmodel {public int retcode {get; set;}        Public Paramresult result = new Paramresult (); public class Paramresult {//////Public List categories =            New List ();            Friends Summary//public List friends = new List ();            Friend Information//public List info = new list ();            Note///public List marknames = new list (); Group//public class Paramcategories {public string I                Ndex {get; set;}                public int sort {get; set;}            public string name {get; set;} }/////Friends Summary//public class Paramfriends {pub                LIC string flag {get; set;} public string UIn {get; SET            public string Categories {get; set;}  }//////public class Paraminfo {public                String face {get; set;}                public string Nick {get; set;}            public string UIn {get; set;} }//////public class Parammarknames {pub                Lic string UIn {get; set;}            public string Markname {get; set;}  }        }    }

Small expansion left join query in LINQThe result information returned above contains 4 objects, using UIn or other to relate to each other, using for loop is OK, of course, there is a more beautiful way to share with you, if not good also ask you to say more comments:
            var query = from F in model.result.friends                        joins I in Model.result.info on F.uin equals I.uin to table1 from                        T1 i n table1. DefaultIfEmpty ()                        join M in model.result.marknames on F.uin equals M.uin to table2 from                        T2 in Table2. DefaultIfEmpty ()                        select New Friend ()                        {                            Uin = F.uin, face                            = T1 = = null? string. Empty:t1.face,                            Category = f.categories,                            Nick = T1 = = null? string. Empty:t1.nick,                            markname = t2 = = null? string. Empty:t2.markname                        };

The above is an associated query using a LEFT JOIN multiple table, which corresponds to the result property of the return JSON

Get Group 1-Request Information
    • Address:http://s.web2.qq.com/api/get_group_name_list_mask2
    • Refererhttp://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1
    • Post string:string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", this.VfWebQQ, this.Hash);
Get Group 2-Return information

Structure and get friends somewhat similar, the difference is: the unique identity of the group is GID, the friend is UIn, the name is different. The following are the corresponding entity classes:

    Class Jsongroupmodel    {public        int Retcode {get; set;}        Public Paramresult result = new Paramresult ();        public class Paramresult        {public            list gnamelist = new list ();            public class Paramgnamelist            {public                string flag {get; set;}                public string gid {get; set;}                public string code {get; set;}                public string name {get; set;}            }        }    
xClose So far, has been able to complete the landing, and remain online, get the message (parsing message not explained), Get friends and group list next I want to write a corresponding demo for each article, to help you better understand the whole process, after all, the article is mainly about the process, You may experience this or that kind of problem in your actual operation. Attaching the demo to the previous article may take a little time, and the planned daily one is more difficult to achieve ... Try it.

Using C # to impersonate an HTTP request can refer to the jab here

Do you have any interest in this article?

It's okay. WQNMLGB

.

Step-by-step to do WEBQQ robot-(iv) (Get Friends List and group list)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.