这是我的第一篇帖子,所以请轻松一下:)
我正在将Android SDK集成到Android应用程序中。在用户登录后,我想向他展示应用程序在Facebook上的最后一篇文章,所以我很想得到它(作为图形对象):
Bundle params = new Bundle();
params.putInt("limit", 1);
Request request = new Request(session, inRequestId + "/posts/?limit=1&access_token=" +
session.getAccessToken().toString(), params, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
if(response != null){
if(response.getError() != null)
Toast.makeText(getActivity(), "Error retrieveng last post", Toast.LENGTH_SHORT).show();
else {
updateFacebookView( response.getGraphObject().getInnerJSONObject() );
}
}
}
});
request.executeAsync();
这很好用,我认为,但是如果我没有使用graphPath的limit = 1参数(inRequestId +“/ posts /?access_token =”+ session.getAccessToken()。toString()),那么没有限制,如果我没有把bundle param“limit”,(作为字符串或int测试),它给了我这个错误:
09-30 17:51:47.094: E/caca(19703): {HttpStatus: 400, errorCode: 190, errorType:
OAuthException, errorMessage: Malformed access token
CAAT76i2gxTgBAKyLzc8SI6y7V1pGJ0fmbLWCtuKdhHIEZAQBA0jYx4YqZB8IgRDJMUlw1XrvZCLJ8kxKdZCRG3LNbrVL8fB34ZBlyvlqadT192MCWMkst1lMSdFwtRVPWiSNfBfi8Gq2RHZCWskrBVTjAwPDKyDMGLSU8sPnXfe0r2tsZBdZCXLCOJGQtE76sJkr7n8SdOU4j1KopkvT0Mux7QBGf7ZBXtCRqDnsZAZCxSNHAZDZD?access_token=CAAT76i2gxTgBAKyLzc8SI6y7V1pGJ0fmbLWCtuKdhHIEZAQBA0jYx4YqZB8IgRDJMUlw1XrvZCLJ8kxKdZCRG3LNbrVL8fB34ZBlyvlqadT192MCWMkst1lMSdFwtRVPWiSNfBfi8Gq2RHZCWskrBVTjAwPDKyDMGLSU8sPnXfe0r2tsZBdZCXLCOJGQtE76sJkr7n8SdOU4j1KopkvT0Mux7QBGf7ZBXtCRqDnsZAZCxSNHAZDZD}
我没有正确使用它或者它是一个错误? 提前致谢
答案 0 :(得分:0)
构造函数的第二个参数是请求的“路径”,但是您也将请求参数放入路径中,这会与Request类可能尝试代表您的其他参数混淆。有几件事要做:
尝试这样的事情:
Bundle params = new Bundle();
params.putInt("limit", 1);
Request request = new Request(session, inRequestId + "/posts", params, HttpMethod.GET, new Request.Callback() {
...
});
request.executeAsync();