Package weibo4j.http

Examples of weibo4j.http.AccessToken


  }

  /*----------------------------Oauth接口--------------------------------------*/

  public AccessToken getAccessTokenByCode(String code) throws WeiboException {
    return new AccessToken(Weibo.client.post(
        WeiboConfig.getValue("accessTokenURL"),
        new PostParameter[] {
            new PostParameter("client_id", WeiboConfig
                .getValue("client_ID")),
            new PostParameter("client_secret", WeiboConfig
View Full Code Here


public class SinaWeibo implements IWeibo {
  Logger logger = Logger.getLogger(SinaWeibo.class.getName());

  @Override
  public long getAllWeiboCount(ICallBackParameter para) {
    AccessToken at = para.getParameter(ICallBackParameter.ACCESS_TOKEN,
        AccessToken.class);

    if (null == at) {
      logger.warning("Access Token is NULL");
    }

    Weibo weibo = new Weibo();
    weibo.setToken(at.getAccessToken());
    Timeline tm = new Timeline();
    try {
      StatusWapper status = tm.getHomeTimeline();
      return status.getTotalNumber();
    } catch (WeiboException e) {
View Full Code Here

  }

  @Override
  public List<Blog> getAllWeibo(ICallBackParameter para, Page page,
      BlogFeature feature) {
    AccessToken at = para.getParameter(ICallBackParameter.ACCESS_TOKEN,
        AccessToken.class);

    if (null == at) {
      logger.warning("Access Token is NULL");
    }

    Weibo weibo = new Weibo();
    weibo.setToken(at.getAccessToken());
    Timeline tm = new Timeline();
    try {
      Paging paging = new Paging();
      if (page.getCount() >= 0) {
        paging.setCount(page.getCount());
View Full Code Here

      HttpServletResponse resp){
    logger.info("redirectMainPage");
    ICallBackParameter para=new CallBackParameterImpl(req.getSession());
    Oauth oauth = new Oauth();
    try {
      AccessToken at = oauth.getAccessTokenByCode(req.getParameter("code"));
      para.putParameter(ICallBackParameter.ACCESS_TOKEN, at);
      logger.info("Access Token:"+at);
      User user=storeService.find(User.class,at.getAccessToken());
      if (user == null){
        user = new User();
        user.setAccessToken(at.getAccessToken());
        storeService.store(user);
      }else {
        logger.info("user:"+user);
      }
    } catch (WeiboException e) {
View Full Code Here

  }

  /*----------------------------Oauth鎺ュ彛--------------------------------------*/

  public AccessToken getAccessTokenByCode(String code) throws WeiboException {
    return new AccessToken(Weibo.client.post(
        WeiboConfig.getValue("accessTokenURL"),
        new PostParameter[] {
            new PostParameter("client_id", WeiboConfig
                .getValue("client_ID")),
            new PostParameter("client_secret", WeiboConfig
View Full Code Here

            RequestToken requestToken = weibo.getOAuthRequestToken();
           
            System.out.println("Got request token.");
            System.out.println("Request token: "+ requestToken.getToken());
            System.out.println("Request token secret: "+ requestToken.getTokenSecret());
            AccessToken accessToken = null;

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            while (null == accessToken) {
                System.out.println("Open the following URL and grant access to your account:");
                System.out.println(requestToken.getAuthorizationURL());
                BareBonesBrowserLaunch.openURL(requestToken.getAuthorizationURL());
                System.out.print("Hit enter when it's done.[Enter]:");
               
                String pin = br.readLine();
                System.out.println("pin: " + br.toString());
                try{
                    accessToken = requestToken.getAccessToken(pin);
                } catch (WeiboException te) {
                    if(401 == te.getStatusCode()){
                        System.out.println("Unable to get the access token.");
                    }else{
                        te.printStackTrace();
                    }
                }
            }
            System.out.println("Got access token.");
            System.out.println("Access token: "+ accessToken.getToken());
            System.out.println("Access token secret: "+ accessToken.getTokenSecret());

           /* weibo.setToken(accessToken.getToken(), accessToken.getTokenSecret());

      Status status = weibo.updateStatus("test message6 ");
      System.out.println("Successfully updated the status to ["
View Full Code Here

          Weibo.CONSUMER_SECRET);

      Weibo weibo = new Weibo();
      // set callback url, desktop app please set to null
      // http://callback_url?oauth_token=xxx&oauth_verifier=xxx
      AccessToken accessToken = weibo.getOAuthAccessToken(requestToken
          .getToken(), requestToken.getTokenSecret(), verifier);

      System.out.println("Got access token.");
      System.out.println("access token: " + accessToken.getToken());
      System.out.println("access token secret: "
          + accessToken.getTokenSecret());
      return accessToken;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

     * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
     * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2.  Obtaining User Authorization</a>
     * @since Weibo 2.0.8
     */
    public synchronized AccessToken getOAuthAccessToken(RequestToken requestToken, String pin) throws WeiboException {
        AccessToken accessToken = http.getOAuthAccessToken(requestToken, pin);
        setUserId(accessToken.getScreenName());
        return accessToken;
    }
View Full Code Here

     * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
     * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2.  Obtaining User Authorization</a>
     * @since Weibo 2.0.1
     */
    public synchronized AccessToken getOAuthAccessToken(String token, String tokenSecret) throws WeiboException {
        AccessToken accessToken = http.getOAuthAccessToken(token, tokenSecret);
        setUserId(accessToken.getScreenName());
        return accessToken;
    }
View Full Code Here

     * @param token token
     * @param tokenSecret token secret
     * @since Weibo 2.0.0
     */
    public void setOAuthAccessToken(String token, String tokenSecret) {
        setOAuthAccessToken(new AccessToken(token, tokenSecret));
    }
View Full Code Here

TOP

Related Classes of weibo4j.http.AccessToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.