QQ Farm plug-in design ideas

Source: Internet
Author: User

The snsgame of the Alumni QQ Farm is based on the HTTP protocol. Therefore, you only need to use tools and software to intercept HTTP data packets to further analyze the meaning of submitted and received data, then simulate a flash client to deal with the server.
 

To achieve this goal, download and install the tool ethereal, which intercepts TCP/IP data packets. After installation, log on to QQ to enter the farm and enable Ethereal to intercept data packets, then, click the refresh friends list button on the farm and go to Ethereal to check the intercepted data packets. The URL address for reading the friends list is:
 

Http://happyfarm.qzone.qq.com/api.php? MoD = friend

The required parameters include login_time, skey, and uin.
 

After knowing the address, you can use Apache httpclient to simulate a flash client. The specific code is as follows:
 

String login_time = configproperties. getproperty ("login_time ");
String skey = configproperties. getproperty ("skey ");
String _ S _ = configproperties. getproperty ("_ S _");
String uin = configproperties. getproperty ("uin ");
Httpclient Hc = new httpclient ();
// Create an instance of the get Method
Getmethod = new getmethod (URL );

//
Getmethod. addrequestheader ("accept ","*/*");
Getmethod
. Addrequestheader (
"User-Agent ",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; sv1;. Net CLR 1.1.4322;. Net CLR 2.0.50727; 360se )");
Getmethod. addrequestheader ("Accept-encoding", "gzip, deflate ");
Getmethod. addrequestheader ("Accept-language", "ZH-CN ");
Getmethod. addrequestheader ("connection", "keep-alive ");
Getmethod. addrequestheader ("Pragma", "No-Cache ");
HC. getstate (). clearcookies ();
//

String cookies = "1" + "; _ S _ =" + _ S _ + "; uin =" + uin + "; skey ="
+ Skey + "; login_time =" + login_time;
HC. getstate (). addcookie (
New cookie ("happyfarm.qzone.qq.com", "jump", cookies ,"/",
New Date (2011, 12, 8), false ));
 

// Execute getmethod
Int statuscode = hc.exe cutemethod (getmethod );
//
String result = getmethod. getresponsebodyasstring ();

In this way, you can find the URL for obtaining information about a friend farm:
 

Http://nc.qzone.qq.com/cgi-bin/cgi_farm_index? MoD = user & act = run & ownerid =
 

When the URL address of a good friend in one or more regions is:
 

Http://nc.qzone.qq.com/cgi-bin/cgi_farm_steal? MoD = farmlandstatus & act = scrounge
 

Okay, all of this is done. In addition, you need to submit a parameter farmkey for the URL address of the stealing dish. This method is difficult to generate. The specific method is as follows:
 

Int curtime = (INT) (system. currenttimemillis ()/1000l );
 

String S = "sdoit78sdopig7w34057 ";
In

T Yushu = curtime % 10;
S = S. substring (Yushu, 20 );
String farmkey = com. sourceware. util. stringutil
. Getmd5 (curtime + S );
 
 

In addition, you need to analyze the data packet format returned by the server. Currently, all data packets are in JSON format,
 

For example, the data in the list of friends is:

[{"Userid": 1905432, "username": "\ u6c38 \ u8fdc \ u7684 \ u9ed1", "headpic": "http: \ // qlogo2.store.qq.com \/qzonelogo \/1265877 \/1 \/1242884728 "," yellowlevel ": 0," yellowstatus ": 0," exp ": 7776, "Money": 38961, "pf": 0 },{ "userid": 159805, "username": "\ u8f7b \ u63cf \ u6de1 \ u5199", "headpic ": "http: \ // imgcache.qq.com \/qzone_v4 \/client \/userinfo_icon \/5001.gif"," yellowlevel ": 0," yellowstatus ": 0," exp ": 20332, "Money": 22665, "pf": 0 },{ "userid": 65178, "username": "Air-F", "headpic is omitted...
 

If Java is used for development, you can use the JSON-lib package for parsing.
 

In addition, sort the returned error prompts as follows:

If {"code": 0, "direction": "is returned, nothing can be picked! "," Farmlandindex ": 2," fkey ":" success "," poptype ": 1}
It should be that this land is mature and has been stripped (mature land has a yield, a surplus number, and the smallest surplus number "through which we can get a maximum of several").
 

If {"code": 0, "direction": "failed to retrieve Farmland Information", "fkey": "success", "poptype": 0} is returned}
So it should be that the land has not yet been mature, or it has been harvested by the master; or this land has nothing to plant;
 

If {"code": 0, "direction": "cannot be greedy! "," Farmlandindex ": 1," fkey ":" empty "," poptype ": 1 },{" code ": 0," direction ":" You cannot be greedy! "," Farmlandindex ": 2," poptype ": 1}
It indicates that you have already completed the renewal and want to continue;

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.