我使用Facebook OpenGraph在我的Android应用程序中发送代码。
我从facebook文档中提取示例(https://developers.facebook.com/docs/android/open-graph)
我的方法适用于listen操作,但不适用于读取操作。 当我尝试发布读取操作(文章对象已成功添加)时出现错误
error: {HttpStatus: 500, errorCode: 1, errorType: OAuthException, errorMessage: An unknown error has occurred.}
我在iOS上制作了相同的应用程序并且两种操作都有效。
这是我发送一个listen动作的方法,对于我刚刚替换的读取动作" music.song"通过"文章"和" music.listens"通过" news.reads":
// Create a batch request
RequestBatch requestBatch = new RequestBatch();
// Set up the OpenGraphObject representing the book.
OpenGraphObject song = OpenGraphObject.Factory.createForPost("music.song");
song.setTitle(myMusicTitle);
song.setDescription(myMusicDescription);
// Set up the object request callback
Request.Callback objectCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
// Log any response error
FacebookRequestError error = response.getError();
if (error != null) {
...
} else {
...
}
}
};
// Create the request for object creation
Request objectRequest = Request.newPostOpenGraphObjectRequest(Session.getActiveSession(),
song, objectCallback);
// Set the batch name so you can refer to the result
// in the follow-on publish action request
objectRequest.setBatchEntryName("objectCreate");
// Add the request to the batch
requestBatch.add(objectRequest);
// Request: Publish action request
// --------------------------------------------
OpenGraphAction readAction = OpenGraphAction.Factory.createForPost("music.listens");
// Refer to the "id" in the result from the previous batch request
readAction.setProperty("song", "{result=objectCreate:$.id}");
// Set up the action request callback
Request.Callback actionCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
...
}
else
{
String actionId = null;
try {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
actionId = graphResponse.getString("id");
} catch (JSONException e) {
...
}
}
}
};
// Create the publish action request
Request actionRequest = Request.newPostOpenGraphActionRequest(Session.getActiveSession(),
readAction, actionCallback);
// Add the request to the batch
requestBatch.add(actionRequest);
// Execute the batch request
requestBatch.executeAsync();
有人知道我为什么会收到此错误吗?
提前致谢。