QQ好友列表获取接口分析,提取qq好友列表数据-获取他人的qq好友

时间: 作者: 点击量:

任何开发前先思考,如果我要一个提取QQ好友列表获取的接口,那么必须找到一个网页在哪里会调用读取用户的qq好友列表

然后这里要你从qq好友列表里面选择,那么这里肯定会出现一个ajax异步读取,这个jajx请求的响应也许就是你的QQ好友列表。

接着在右边开发者工具里面会抓到很多请求包,那么你能一眼从众多的请求包中发现friend_show_qqfriends是显示QQ好友列表。

然后返回的json里面uin是QQ,groupid是分组id,remark是备注之类的。

QQ空间的,qq获取好友接口:http://user.qzone.qq.com/p/r/cgi-bin/tfriend/friend_show_qqfriends.cgi?uin=867597730&follow_flag=1&groupface_flag=0&fupdate=1&g_tk=20372033
返回

_Callback({
“code”:0,
“subcode”:0,
“message”:””,
“default”:0,
“data”:
{“items”:[{“uin”:79620,
“groupid”:15,
“name”:”提取QQ好友列表”,
“remark”:”QQ”,
“img”:”http://qlogo1.store.qq.com/qzone/79620/79620/30″,
“yellow”:-1,
“online”:0,
“v6”:1},


这个接口返回格式是callback的回调函数也就是意味着可以跨域获取?但是别忘记了这个接口请求需要带上一个参数也就是g_tk,这个g_tk是要用skey和QQ来计算的,并且需要验证cookie,所以意味着你也无法通过穷举g_tk来获取他人的qq好友列表,因此这个接口的安全性是不容置疑的。

 

package org.myJsoup;
 
import java.io.IOException;
import java.util.List;
import java.util.Map;
 
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
 
import com.fasterxml.jackson.databind.ObjectMapper;
import com.testmail.MailUtilByYock;
 
public class QZoneCrawlFriends {
    public static void main(String[] args) throws IOException {
        CloseableHttpClient client = HttpClientBuilder.create().build();
        HttpGet get = new HttpGet("https://h5.qzone.qq.com/proxy/domain/r.qzone.qq.com/cgi-bin/tfriend/friend_show_qqfriends.cgi?uin=1968568204&follow_flag=1&groupface_flag=0&fupdate=1&g_tk=2163927521");
        get.addHeader("Accept",
                "*/*");
        get.addHeader("Accept-Encoding", "gzip,deflate,sdch");
        get.addHeader("Accept-Language", "zh-CN,zh;q=0.8");
        get.addHeader("referer", "http://user.qzone.qq.com/2163927521");
        get.addHeader(
                "User-Agent",
                "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
        get.addHeader("Cookie","pgv_pvid=2163927521; pgv_info=ssid=s2163927521; rv2=80EE89992BE55328CF8338C99CFAEE34CBBC055C4F5ECF894A; property20=A7B48B66A2D072B8FF5247EDB8EDE20A6C9898B2079E2E522E2A57D73C545AFBB41C103681E2A7E5; __Q_w_s_hat_seed=1; __Q_w_s__QZN_TodoMsgCnt=1; pgv_pvi=2163927521; pgv_si=s2163927521; RK=p8ULeKXiGJ; ptui_loginuin=2163927521; ptisp=cnc; ptcz=deee8e0b7cc45b3e11aed27680441216e0f1de716869ceff0772f5c5dd54cf18; pt2gguin=o1968568204; uin=o2163927521; skey=@GmTwovsnK; p_uin=o2163927521; p_skey=g5EU8BU5M50Eg1Ry4*xxDFaBgCOLo2liCSUgI2VIIYg_; pt4_token=PZ9V0DRBiVLhaupZk*KSn3XXK7TZaYVpkZBzxaD08i8_; Loading=Yes; qzspeedup=sdch; blabla=dynamic; QZ_FE_WEBP_SUPPORT=1; cpu_performance_v8=1");
        try {
            CloseableHttpResponse response = client.execute(get);
            String bodyAsString = EntityUtils.toString(response.getEntity());
            bodyAsString = bodyAsString.substring(10,bodyAsString.length()-2);
            ObjectMapper objectMapper = new ObjectMapper();
             
             
            StringBuffer sb = new StringBuffer();
            sb.append("<html><head></head><body>");
            Map map = objectMapper.readValue(bodyAsString, Map.class);
            Map map2 = (Map) map.get("data");
            List<Map> map3 = (List<Map>) map2.get("items");
            for (int i = 0; i < map3.size(); i++) {
                sb.append("<p><img src="+map3.get(i).get("img")+"/>"+map3.get(i).get("uin") + "\n"
                        + "昵称:"+map3.get(i).get("name")+"("+map3.get(i).get("remark")+")"+"\n</P>");
            }
            sb.append("</body></html>");
            String receiveEmail = "2163927521@qq.com";
            String receiveNick = "longyi";
            String subject = "Your QQ friends:";
            String contents = sb.toString();
            MailUtilByYock.sendMail(receiveEmail, receiveNick, subject, contents);
            response.close();
            client.close();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
         
 
    }
}

 

上一篇:最新解封永久冻结QQ解封方法技巧 亲测qq解封成功

下一篇:QQ好友列表数据获取分析 -qq好友提取导出协议

注册体验: