twitter4j.Twitter.createFriendship()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中twitter4j.Twitter.createFriendship()方法的一些代码示例,展示了Twitter.createFriendship()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Twitter.createFriendship()方法的具体详情如下:
包路径:twitter4j.Twitter
类名称:Twitter
方法名:createFriendship

Twitter.createFriendship介绍

[英]Befriends the user specified in the ID parameter as the authenticating user. Returns the befriended user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
[中]与ID参数中指定为身份验证用户的用户成为好友。成功时以请求的格式返回好友用户。返回一个字符串,描述失败时的失败条件。

代码示例

代码示例来源:origin: net.homeip.yusuke/twitter4j

/**
 * Befriends the user specified in the ID parameter as the authenticating user.  Returns the befriended user in the requested format when successful.  Returns a string describing the failure condition when unsuccessful.
 *
 * @param id the ID or screen name of the user to be befriended
 * @return the befriended user
 * @throws TwitterException when Twitter service or network is unavailable
 * @deprecated Use createFriendship(String id) instead
 * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-friendships%C2%A0create">Twitter API Wiki / Twitter REST API Method: friendships create</a>
 */
public User create(String id) throws TwitterException {
  return createFriendship(id);
}

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    User user = twitter.createFriendship(userId);
    for (TwitterListener listener : listeners) {
      try {
        listener.createdFriendship(user);
      } catch (Exception e) {
        logger.warn("Exception at createdFriendship", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    User user = twitter.createFriendship(userId, follow);
    for (TwitterListener listener : listeners) {
      try {
        listener.createdFriendship(user);
      } catch (Exception e) {
        logger.warn("Exception at createdFriendship", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    User user = twitter.createFriendship(screenName);
    for (TwitterListener listener : listeners) {
      try {
        listener.createdFriendship(user);
      } catch (Exception e) {
        logger.warn("Exception at createdFriendship", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    User user = twitter.createFriendship(screenName, follow);
    for (TwitterListener listener : listeners) {
      try {
        listener.createdFriendship(user);
      } catch (Exception e) {
        logger.warn("Exception at createdFriendship", e);
      }
    }
  }
});

代码示例来源:origin: stackoverflow.com

ConfigurationBuilder cb =new ConfigurationBuilder();
   cb.setDebugEnabled(true)
    .setOAuthConsumerKey("******")
    .setOAuthConsumerSecret("******")
    .setOAuthAccessToken("*******")
    .setOAuthAccessTokenSecret("********");
   //In case of proxy 
   //cb.setHttpProxyHost("******").setHttpProxyPort(8080);
   TwitterFactory twitterFactory=new TwitterFactory(cb.build());
   Twitter twitter=twitterFactory.getInstance();
    twitter.createFriendship("twitter id");

代码示例来源:origin: stackoverflow.com

twitter.createFriendship(screenName);

代码示例来源:origin: Tristan971/Lyrebird

/**
 * Follows a given user.
 *
 * @param user the user to follow.
 *
 * @return the followed user
 */
User follow(final User user) {
  return sessionManager.doWithCurrentTwitter(twitter -> twitter.createFriendship(user.getId()))
             .onSuccess(userFollowed -> LOG.debug(
                 "User {} followed user {}",
                 getCurrentScreenName(),
                 userFollowed.getScreenName()
             ))
             .onFailure(err -> displayExceptionPane("Could not follow user!", err.getMessage(), err))
             .get();
}

代码示例来源:origin: stackoverflow.com

try {
  Twitter twitter = new TwitterFactory().getInstance();
  twitter.createFriendship("Dan");
  System.out.println("Successfully followed [Dan].");
  System.exit(0);

相关文章