V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
RelativeLayout
V2EX  ›  程序员

做了一个weibo自动登陆,授权和获取token的php脚本

  •  
  •   RelativeLayout ·
    daimajia · 2013-02-04 19:45:31 +08:00 · 5102 次点击
    这是一个创建于 4069 天前的主题,其中的信息可能已经有所发展或是发生改变。
    想到weico每次添加账户不需要跳转到浏览器就行oauth授权,于是花了点儿时间做了个后台程序,实现了相同功能。

    https://github.com/xuanqinanhai/weibo-simulator

    求star,求fork,求pull request。

    希望大家合力来支持更多平台。
    6 条回复    2014-05-22 00:18:34 +08:00
    RelativeLayout
        1
    RelativeLayout  
    OP
       2013-02-20 11:23:02 +08:00
    难道真的没有人用的上么?
    RelativeLayout
        2
    RelativeLayout  
    OP
       2013-02-20 11:25:24 +08:00
    这次更新还添加了本地的Python认证,跳过了浏览器
    xing393939
        3
    xing393939  
       2013-02-20 13:23:23 +08:00
    不是有验证码的吗
    arzusyume
        4
    arzusyume  
       2013-02-20 13:27:39 +08:00
    sina登录如果IP为国外或者user-agant里有奇怪的东西(比如sae)时,需要验证码。。。
    RelativeLayout
        5
    RelativeLayout  
    OP
       2013-02-20 14:53:36 +08:00
    @arzusyume 没有处理验证码诶。过两天处理验证码。
    snnn
        6
    snnn  
       2014-05-22 00:18:34 +08:00
    Gson gson = new Gson();
    java.util.List<NameValuePair> formparams = new java.util.ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("client_id", appid));
    formparams.add(new BasicNameValuePair("client_secret", appkey));
    formparams.add(new BasicNameValuePair("grant_type", "password"));
    formparams.add(new BasicNameValuePair("username", username));
    formparams.add(new BasicNameValuePair("password", password));
    org.apache.http.client.fluent.Response httpres = Request.Post("https://api.weibo.com/oauth2/access_token")
    .bodyForm(formparams).execute();

    org.apache.http.HttpResponse resp = httpres.returnResponse();

    client_id=140226478

    client_secret=42fcc96d3e64d9e248649369d61632a6
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5456 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 08:51 · PVG 16:51 · LAX 01:51 · JFK 04:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.