我正在尝试使用twitter api for android取消关注用户,
端点:https://api.twitter.com/1.1/friendships/destroy.json(doc)
Java代码:
接口:
interface GetUnfollowService{
@POST("/1.1/friendships/destroy.json")
Call<ResponseBody> destroy(@Query("user_id") Long userID);
}
&#13;
MyTwitterApiClient.java
class MyTwitterApiClient extends TwitterApiClient {
public MyTwitterApiClient(TwitterSession session) {
super(session);
}
public GetUserData getUserData(){return getService(GetUserData.class);}
public GetUnfollowService getUnfollowService(){ return getService(GetUnfollowService.class);}
我的申请:
TwitterSession twitterSession = TwitterCore.getInstance().getSessionManager().getActiveSession();
MyTwitterApiClient myTwitterApiClient = new MyTwitterApiClient(twitterSession);
Long userID = userTwitterData.getNot_following_back_ids().get(i);
Call<ResponseBody> cb = myTwitterApiClient.getUnfollowService().destroy(userID);
cb.enqueue(new Callback<ResponseBody>() {
@Override
public void success(Result<ResponseBody> result) {
Toast.makeText(NonFollowers.this, "Hi", Toast.LENGTH_SHORT).show();
}
@Override
public void failure(TwitterException exception) {
Toast.makeText(NonFollowers.this, "Bye", Toast.LENGTH_SHORT).show();
}
});
我收到HTTP错误401,有人可以告诉我在哪里做错了。