Esempio n. 1
0
 /**
  * フォロー/アンフォロー処理を実行します。
  *
  * @param twitter
  * @param mode
  * @param targetList
  */
 public static void doProcessIds(Twitter twitter, int mode, List<Long> targetList) {
   if (targetList.size() > 0) {
     if (mode == DOREMOVE && 1000 <= targetList.size()) {
       log.info("アンフォロー件数が1000を超えているため、中止します。 removeSize:" + targetList.size() + "]");
       return;
     }
     for (int i = 0; i < targetList.size(); i++) {
       long id = targetList.get(i);
       if (id <= 0) {
         continue;
       }
       try {
         if (mode == DOREMOVE) {
           twitter.destroyFriendship(id);
           log.info("remove: " + id);
         } else if (mode == DOFOLLOW) {
           twitter.createFriendship(id);
           log.info("follow: " + id);
         }
       } catch (TwitterException e) {
         log.info(e.getMessage());
       }
     }
   }
 }
    @Override
    protected Void doInBackground(String... urls) {
      Twitter twit = Utils.getTwitter(context, settings);

      try {
        twit.createFriendship("lukeklinker");
      } catch (Exception x) {

      }

      try {
        twit.createFriendship("TalonAndroid");
      } catch (Exception x) {

      }

      return null;
    }
Esempio n. 3
0
 /**
  * Usage: java twitter4j.examples.friendship.CreateFriendship [screen name]
  *
  * @param args message
  */
 public static void main(String[] args) {
   if (args.length < 1) {
     System.out.println(
         "Usage: java twitter4j.examples.friendship.CreateFriendship [screen name]");
     System.exit(-1);
   }
   try {
     Twitter twitter = new TwitterFactory().getInstance();
     twitter.createFriendship(args[0]);
     System.out.println("Successfully followed [" + args[0] + "].");
     System.exit(0);
   } catch (TwitterException te) {
     te.printStackTrace();
     System.out.println("Failed to follow: " + te.getMessage());
     System.exit(-1);
   }
 }