我正在尝试使用 Android Facebook SDK 发送一个简单的请求。这是我的代码:
Session.openActiveSession( NATIVE_ACTIVTY, true, new Session.StatusCallback()
{
@Override
public void call(Session session, SessionState state, Exception exception)
{
Request.Callback callback= new Request.Callback()
{
public void onCompleted(Response response)
{
if( response.getError() != null)
{
Log.i( "Output", response.toString());
// Here i'm checking token, permissions, ...
}
}
};
Bundle params = new Bundle();
params.putString("access_token", session.getAccessToken());
params.putString("name", name);
params.putString("caption", caption);
params.putString("description", description);
params.putString("link", link);
params.putString("picture", picture);
Request request = new Request( session, "me/feed/", params, HttpMethod.POST, callback );
request.executeAsync();
Log.i( "Output", request.toString() );
}
}
但是请求失败,响应是:
I/Output(29990): {Response: responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}
有错误
I/Output(29990): com.facebook.FacebookException: could not construct request body
我还检查了几件事:
- 权限没问题;
- access_token 有效(https://graph.facebook.com/me?access_token= {my_token} 在我的浏览器中工作正常)
- 会话状态为 OPENED
我不明白为什么它不起作用,我真的不知道该怎么办......
非常感谢