List of usage examples for twitter4j Twitter showFriendship
Relationship showFriendship(long sourceId, long targetId) throws TwitterException;
From source file:ShowFriendshi.java
License:Apache License
/** * Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name] * * @param args message/*from ww w. j av a 2s. com*/ */ public ArrayList<Long> showFriendship() { GetFriendsIDs getFriendsId = new GetFriendsIDs(); ArrayList<Long> target = getFriendsId.getFriendsId(); ArrayList<Long> filteredTarget = new ArrayList<Long>(); Collections.shuffle(target); try { Twitter twitter = new TwitterFactory().getInstance(); int authenticatedUserId = (int) twitter.getId(); if (target.size() < 50) { for (int i = 0; i < target.size(); i++) { Relationship relationship = twitter.showFriendship(authenticatedUserId, target.get(i)); if (!relationship.isSourceFollowedByTarget()) { filteredTarget.add(target.get(i)); } } } else { for (int i = 0; i < 50; i++) { Relationship relationship = twitter.showFriendship(authenticatedUserId, target.get(i)); if (!relationship.isSourceFollowedByTarget()) { filteredTarget.add(target.get(i)); } } } } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to show friendship: " + te.getMessage()); } return filteredTarget; }
From source file:com.javielinux.infos.InfoUsers.java
License:Apache License
public void checkFriend(Context context, String name) { if (!hasFriendly(name)) { addFriendly(name);//from w ww . j a v a2 s . c o m } if (!isCheckFriendly(name)) { Friend friend = friendly.get(name); try { //Entity ent = DataFramework.getInstance().getTopEntity("users", "name = '"+getName()+"'", ""); ConnectionManager.getInstance().open(context); Twitter twitter = ConnectionManager.getInstance().getUserForSearchesTwitter(); Relationship relationship = twitter.showFriendship(getName(), name); friend.friend = relationship.isSourceFollowingTarget(); friend.follower = relationship.isSourceFollowedByTarget(); friend.checked = true; friendly.remove(name); friendly.put(name, friend); } catch (TwitterException e) { e.printStackTrace(); } } }
From source file:com.michaelfitzmaurice.clocktwerk.apps.FollowChecker.java
License:Apache License
public static void main(String[] args) throws Exception { String source = args[0];//from w w w .j a v a2 s .c om String target = args[1]; LOG.info("Setting up Twitter client..."); Twitter twitter = new TwitterFactory().getInstance(); LOG.info("Twitter client connected"); LOG.info("Inspecting Twitter relationship between {} and {} ", source, target); Relationship relationship = twitter.showFriendship(source, target); boolean targetFollowsSource = relationship.isSourceFollowedByTarget(); boolean sourceFollowsTarget = relationship.isSourceFollowingTarget(); LOG.info("{} follows {}: {}", new Object[] { target, source, targetFollowsSource }); LOG.info("{} follows {}: {}", new Object[] { source, target, sourceFollowsTarget }); }
From source file:com.SocialAccess.TwitterSearch.java
public static String[] FriendshipStatus(String[] args) { if (args.length < 2) { System.out.println("Usage: [source screen name] [target screen name]"); System.exit(-1);//from www .j ava 2 s .c om } String[] lineConnection = new String[2]; try { Twitter twitter = new TwitterFactory().getInstance(); Relationship relationship = twitter.showFriendship(args[0], args[1]); lineConnection[0] = args[0] + " is followed by " + args[1] + " " + relationship.isSourceFollowedByTarget(); lineConnection[1] = args[0] + " is following " + args[1] + " " + relationship.isSourceFollowingTarget(); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to show friendship: " + te.getMessage()); System.exit(-1); } return lineConnection; }
From source file:de.vanita5.twittnuker.loader.support.ParcelableUserLoader.java
License:Open Source License
private static User showUserAlternative(final Twitter twitter, final long id, final String screenName) throws TwitterException { final String searchScreenName; if (screenName != null) { searchScreenName = screenName;/*w w w.j av a 2 s . c om*/ } else if (id != -1) { searchScreenName = twitter.showFriendship(twitter.getId(), id).getTargetUserScreenName(); } else return null; for (final User user : twitter.searchUsers(searchScreenName, 1)) { if (user.getId() == id || searchScreenName.equals(user.getScreenName())) return user; } return null; }
From source file:org.getlantern.firetweet.util.TwitterWrapper.java
License:Open Source License
@NonNull public static User showUserAlternative(final Twitter twitter, final long id, final String screenName) throws TwitterException { final String searchScreenName; if (screenName != null) { searchScreenName = screenName;/*from www.j a v a 2 s .c om*/ } else if (id != -1) { searchScreenName = twitter.showFriendship(twitter.getId(), id).getTargetUserScreenName(); } else throw new IllegalArgumentException(); final Paging paging = new Paging(); paging.count(1); if (id != -1) { final ResponseList<Status> timeline = twitter.getUserTimeline(id, paging); for (final Status status : timeline) { final User user = status.getUser(); if (user.getId() == id) return user; } } else { final ResponseList<Status> timeline = twitter.getUserTimeline(screenName, paging); for (final Status status : timeline) { final User user = status.getUser(); if (searchScreenName.equalsIgnoreCase(user.getScreenName())) return user; } } for (final User user : twitter.searchUsers(searchScreenName, 1)) { if (user.getId() == id || searchScreenName.equalsIgnoreCase(user.getScreenName())) return user; } throw new TwitterException("can't find user"); }
From source file:twitter4j.examples.friendship.ShowFriendship.java
License:Apache License
/** * Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name] * * @param args message/*from w ww. ja va2s . co m*/ */ public static void main(String[] args) { if (args.length < 2) { System.out.println( "Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); Relationship relationship = twitter.showFriendship(args[0], args[1]); System.out.println("isSourceBlockingTarget: " + relationship.isSourceBlockingTarget()); System.out.println("isSourceFollowedByTarget: " + relationship.isSourceFollowedByTarget()); System.out.println("isSourceFollowingByTarget: " + relationship.isSourceFollowingTarget()); System.out.println("isSourceNotificationsEnabled: " + relationship.isSourceNotificationsEnabled()); System.out.println("canSourceDm: " + relationship.canSourceDm()); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to show friendship: " + te.getMessage()); System.exit(-1); } }