Package weibo4j

Examples of weibo4j.Oauth


import weibo4j.model.WeiboException;
import weibo4j.util.BareBonesBrowserLaunch;

public class OAuth4Code {
  public static void main(String [] args) throws WeiboException, IOException{
    Oauth oauth = new Oauth();
    BareBonesBrowserLaunch.openURL(oauth.authorize("code"));
    System.out.println(oauth.authorize("code"));
    System.out.print("Hit enter when it's done.[Enter]:");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String code = br.readLine();
    Log.logInfo("code: " + code);
    try{
      System.out.println(oauth.getAccessTokenByCode(code));
    } catch (WeiboException e) {
      if(401 == e.getStatusCode()){
        Log.logInfo("Unable to get the access token.");
      }else{
        e.printStackTrace();
View Full Code Here


 
  private void redirectMainPage(HttpServletRequest req,
      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();
View Full Code Here

  @Override
  public void redirectAuthPage(HttpServletRequest req,
      HttpServletResponse resp) throws IOException {
    // TODO Auto-generated method stub
    Oauth oauth = new Oauth();
    try {
      resp.sendRedirect(oauth.authorize("code"));
      logger.info("redirectAuthPage");
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here

import weibo4j.model.WeiboException;
import weibo4j.util.BareBonesBrowserLaunch;

public class OAuth4Code {
  public static void main(String[] args) throws WeiboException, IOException {
    Oauth oauth = new Oauth();
    BareBonesBrowserLaunch.openURL(oauth.authorize("code", args[0], args[1]));
    System.out.println(oauth.authorize("code", args[0], args[1]));
    System.out.print("Hit enter when it's done.[Enter]:");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String code = br.readLine();
    Log.logInfo("code: " + code);
    try {
      System.out.println(oauth.getAccessTokenByCode(code));
    } catch (WeiboException e) {
      if (401 == e.getStatusCode()) {
        Log.logInfo("Unable to get the access token.");
      } else {
        e.printStackTrace();
View Full Code Here

import java.io.InputStreamReader;

public class OAuth4Code {

  public static void main(String[] args) throws WeiboException, IOException {
    Oauth oauth = new Oauth();

    BareBonesBrowserLaunch.openURL(oauth.authorize("code", "", ""));
    System.out.println(oauth.authorize("code", "", ""));
    System.out.print("Hit enter when it's done.[Enter]:");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String code = br.readLine();
    Log.logInfo("code: " + code);
    try {
      System.out.println(oauth.getAccessTokenByCode(code));
    } catch (WeiboException e) {
      if (401 == e.getStatusCode()) {
        Log.logInfo("Unable to get the access token.");
      } else {
        e.printStackTrace();
View Full Code Here

TOP

Related Classes of weibo4j.Oauth

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.