如何使用 Fabric sdk 为 twitter android 应用添加关注或创建友谊这里是链接 https://docs.fabric.io/android/twitter/index.html 我无法从 Fabric 文档中获取信息以供关注
问问题
771 次
2 回答
2
这里是答案实际上它需要为 api 调用建立的端点,这已经不可用了
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);
}
}
然后使用它
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();
}
});
于 2015-09-24T12:35:44.570 回答
0
@SunilRaikwar,创建方法必须将Call< User >作为返回值,而不是作为参数:
public class TwitterFollowApi extends TwitterApiClient {
public TwitterFollowApi(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")
Call<User> create(@Query("screen_name") String screen_name, @Query("twitterLike") boolean follow);
}
}
于 2017-01-05T17:20:59.730 回答