我正在为 Android 使用更新的 Facebook SDK V3.0 final。我正在尝试向没有该应用程序的 Facebook 朋友发送应用程序请求。代码是:
public void fbookinvite(){
Bundle postParams = new Bundle();
postParams.putString("name", "X");
postParams.putString("message", "DOWNLOAD X.");
Session session = Session.getActiveSession();
postParams.putString("access_token", session.getAccessToken());
if (session==null||session.getState().isClosed()){
System.out.println("session is null");
}else{
//meaning we are good to go.
Request request = new Request(session,"/friend facebook id/apprequests", postParams, HttpMethod.POST, new Request.Callback() {
@Override
public void onCompleted(Response response) {
System.out.println("response was: "+response.toString());
}
});
Request.executeBatchAsync(request);
}
}
当代码运行时,我从打印的响应中得到以下内容之一:
responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2, errorType: OAuthException, errorMessage: (#2) Failed to create any app request}, isFromCache:false
... 或者:
Response: responseCode: unknown, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}
我有以下权限:publist_stream
和publish_actions
.
解决问题后,我还想知道如何将一组收件人添加到应用请求中。
我不想使用 Facebook 对话框。