HttpClient4模拟登录腾讯微博及分享功能
来源:互联网 发布:手机淘宝支付流程图 编辑:程序博客网 时间:2024/04/30 01:45
package com.wolf.httpclient;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
public class TencentClient {
/**
* @param args
*/
public static void main(String[] args) {
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(
HttpConnectionParams.CONNECTION_TIMEOUT, 5000);
try {
/*********************获取验证码***********************/
HttpGet get = new HttpGet(
"http://ptlogin2.qq.com/check?uin="+用户名或QQ号+"&appid=46000101&r=0.37908964480776913");
HttpResponse response = client.execute(get);
String entity = EntityUtils.toString(response.getEntity());
String[] checkNum = entity.substring(entity.indexOf("(") + 1,
entity.lastIndexOf(")")).replace("'", "").split(",");
System.out.println(checkNum[1]);
String pass="";
/******************** *加密密码***************************/
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("javascript");
String jsFileName = "src/md5.js"; //指定md5加密文件
// 读取js文件
FileReader reader;
reader = new FileReader(jsFileName);
engine.eval(reader);
if (engine instanceof Invocable) {
Invocable invoke = (Invocable) engine;
// 调用preprocess方法,并传入两个参数密码和验证码
pass = (String)invoke.invokeFunction("preprocess", 密码,checkNum[1]);
System.out.println("c = " + pass);
}
reader.close();
/*************************登录****************************/
get=new HttpGet("http://ptlogin2.qq.com/login?ptlang=2052&u=用户名或QQ号&p="+pass+"&verifycode="+checkNum[1]+"&low_login_enable=1&low_login_hour=720&aid=46000101&u1=http%3A%2F%2Ft.qq.com&ptredirect=1&h=1&from_ui=1&dumy=&fp=loginerroralert&action=4-13-11101&dummy=");
System.out.println(get.getURI());
response = client.execute(get);
entity = EntityUtils.toString(response.getEntity());
System.out.println(entity);
/*************************分享*************************/
HttpPost post = new HttpPost("http://radio.t.qq.com/publish.php");
//这句很重要
post.addHeader("Referer","http://radio.t.qq.com/share.php?title=%E4%B9%8C%E9%B2%81%E6%9C%A8%E9%BD%90%E5%B8%82%E5%A4%A7%E9%A3%8E%E8%87%B473%E4%BA%BA%E5%8F%97%E4%BC%A4%203%E4%BA%BA%E6%AD%BB%E4%BA%A1(%E5%9B%BE)&url=http://news.qq.com/a/20120331/000027.htm&pref=qqcom.dp.tmblog&source=qqnews");
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("content", "乌鲁木齐市大风致73人受伤 3人死亡(图) http://news.qq.com/a/20120331/000027.htm (分享自 @腾讯新闻 )"));
nvps.add(new BasicNameValuePair("countType", ""));
nvps.add(new BasicNameValuePair("pic", ""));
nvps.add(new BasicNameValuePair("source", "1000001"));
nvps.add(new BasicNameValuePair("sourcepic", "http://img1.gtimg.com/news/pics/hv1/125/130/1010/65708525.jpg"));
nvps.add(new BasicNameValuePair("viewModel", "0"));
nvps.add(new BasicNameValuePair("wizardpref","qqcom.dp.tmblog"));
nvps.add(new BasicNameValuePair("wizardurl", "http://news.qq.com/a/20120331/000027.htm"));
post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
response = client.execute(post);
entity = EntityUtils.toString(response.getEntity());
System.out.println(entity);
} catch (Exception e) {
// TODO: handle exception
}
}
}
- HttpClient4模拟登录腾讯微博及分享功能
- HttpClient4模拟登录腾讯微博及分享功能
- (最新)HttpClient4模拟登录腾讯微博
- (最新)HttpClient4模拟登录腾讯微博 .
- httpClient4模拟登录新浪微博
- 腾讯微博模拟登录
- android 腾讯微博分享功能实现及自定义webview认证
- 实战新浪微博、腾讯微博的分享功能
- 实战新浪微博、腾讯微博的分享功能
- 实战新浪微博、腾讯微博的分享功能
- HttpClient4.4.1模拟登录知乎
- httpclient4.3简单封装,模拟登录
- HttpClient4.4.1模拟登录知乎
- HttpClient4.4.1模拟登录知乎
- 腾讯微博分享
- C# 实现模拟登录功能,实现公共类分享。
- 分享功能(分享到新浪微博、腾讯微博、人人网、QQ空间。。。)
- 使用share SDK实现腾讯微博授权登录分享(1.x版本)
- windows xp emacsclientw 不起作用
- 跳跃表数据结构
- 《学习OpenCV》第二章(3)
- 腾讯登录加密方式的java实现
- 设计模式学习(2)
- HttpClient4模拟登录腾讯微博及分享功能
- 如何快速成为javascript高手?
- 游戏王千金囊开发实录二 —— 登录
- iphone开发-地图注解(地图上的大头针)
- 我自己通用的线程池
- (最新)HttpClient4模拟登录腾讯微博 .
- Launcher 拖拽 流程小结『android 2.3 2.2』
- Linux基本命令
- JDBC访问所有数据库的完整步骤