twitter-follow

how to add Follow or create Friendship using Fabric sdk


how to add Follow or create Friendship using Fabric sdk for twitter android app here is the link https://docs.fabric.io/android/twitter/index.html i am unable to get information from fabrics docs for follow


Solution

  • here is the answer Actually its required end point to be made for the api calls which is not available already

    public class TwitterFollow extends TwitterApiClient {
            public TwitterFollow(TwitterSession session) {
                super(session);
            }
            public FollowService getFollowService() {
                return getService(FollowService.class);
            }
    
            /*interface used for Auth Api call for CreateFriendship*/
            public interface FollowService {
                @POST("/1.1/friendships/create.json")
                public void create(@Query("screen_name") String screen_name, @Query("user_id") String user_id, @Query("follow") boolean follow, Callback<User> cb);
            }
        }
    

    and then using it

    TwitterFollow apiClient = new TwitterFollow(session);
    apiClient.getFollowService().create(TWITTER_ACCOUNT_NAME, null, true, new Callback<User>() {
                                @Override
                                public void success(Result<User> result) {
                                    Toast.makeText(this, "Thanks for following!", Toast.LENGTH_SHORT).show();
                                }
    
                                @Override
                                public void failure(TwitterException e) {
                                    Toast.makeText(this, "Error following", Toast.LENGTH_SHORT).show();
                                }
                            });