Package weibo4j

Examples of weibo4j.Weibo


import weibo4j.model.WeiboException;

public class GetBilateralTimeline {
  public static void main(String[] args) {
    String access_token = args[0];
    Weibo weibo = new Weibo();
    weibo.setToken(access_token);
    Timeline tm = new Timeline();
    try {
      StatusWapper status = tm.getBilateralTimeline();
      for(Status s : status.getStatuses()){
        Log.logInfo(s.toString());
View Full Code Here


    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

    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

          }
         
          System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
          System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
         
            Weibo weibo = new Weibo();
           
            /*
       * 此处需要填写AccessToken的key和Secret,可以从OAuthUpdate的执行结果中拷贝过来
             */
            weibo.setToken("e42f35bd66fce37d7c6dfeb6110d8957", "a1943b8ea10eb708e67825d25675d246");
           
            Status status = weibo.updateStatus("你好吗?");
           
            System.out.println("Successfully updated the status to [" + status.getText() + "].");
            System.exit(0);
        } catch (WeiboException te) {
            System.out.println("Failed to get timeline: " + te.getMessage());
View Full Code Here

          }
     
      System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
      System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);

      Weibo weibo = new Weibo();
     
      /*
       * 此处需要填写AccessToken的key和Secret,可以从OAuthUpdate的执行结果中拷贝过来
             */
      weibo.setToken(args[0], args[1]);
      try {
        File file=new File(args[2]);
        if(file==null){
          System.out.println("file is null");
          System.exit(-1);
        }
       
        User user = weibo.updateProfileImage(file);

        System.out.println("Successfully upload the status to ["
            + user.getName() + "].");
       
      } catch (Exception e1) {
View Full Code Here

        try {
          System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
          System.setProperty("weibo4j.oauth.consumerSecret", 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
            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;
View Full Code Here

                "Usage: java weibo4j.examples.Update ID Password text");
            System.exit( -1);
        }
       
        long l1 = System.currentTimeMillis();
        Weibo weibo = new Weibo(args[0], args[1]);
//        System.out.println(weibo.getRateLimitStatus());
       
        List<Status> statuses = weibo.getPublicTimeline();
       
        for (Status status : statuses) {
      System.out.println(status);
    }
       
        String msg = args[2] + new java.util.Date();
       
        // normal status
         Status status = weibo.updateStatus(args[2] + System.currentTimeMillis());
        // status with geocode
    try {
      status = weibo.updateStatus(msg, 40.7579, -73.985);
    } catch (JSONException e1) {
      e1.printStackTrace();
    }
       
        long l2 = System.currentTimeMillis();
       
        System.out.println("Successfully updated the status to [" + status.getText() + "].");
        System.out.println("Time elapsed: " + (l2 - l1));
       
        try {
      Thread.sleep(1000); // avoid flush server
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
        // add a comment for the status
        long sid = status.getId();
        Comment cmt = weibo.updateComment("评论1 " + new java.util.Date(),  String.valueOf(sid), null);
       
        weibo.getComments(String.valueOf(sid));
       
        weibo.updateComment("评论2 " + new java.util.Date(),  String.valueOf(sid), null);

    try {
      Thread.sleep(1000); // avoid flush server
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    Comment cmt2 = weibo.destroyComment(cmt.getId());
    System.out.println("delete " + cmt2);
    }
View Full Code Here

                    "Usage: java weibo4j.examples.GetTimelines ID Password");
                System.exit(0);
            }

            // Other methods require authentication
            Weibo weibo = new Weibo(args[0], args[1]);
            List<Status> statuses = weibo.getPublicTimeline();
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":" +
                                   status.getText());
            }

            statuses = weibo.getFriendsTimeline();
            System.out.println("------------------------------");
            System.out.println("Showing " + args[0] + "'s friends timeline.");
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":" +
                                   status.getText());
            }
            statuses = weibo.getUserTimeline();
            System.out.println("------------------------------");
            System.out.println("Showing " + args[0] + "'s timeline.");
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":" +
                                   status.getText());
View Full Code Here

    try {
      System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
      System.setProperty("weibo4j.oauth.consumerSecret",
          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
      RequestToken requestToken = weibo.getOAuthRequestToken(backUrl);

      System.out.println("Got request token.");
      System.out.println("Request token: " + requestToken.getToken());
      System.out.println("Request token secret: "
          + requestToken.getTokenSecret());
View Full Code Here

    try {
      System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
      System.setProperty("weibo4j.oauth.consumerSecret",
          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: "
View Full Code Here

TOP

Related Classes of weibo4j.Weibo

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.