我正试图在Android上使用开放图表在Facebook上发布代码,我在第一部分使用已定义的动作类型'Listen'(由Facebook设置),但这个只能由Facebook合作伙伴使用:
您最近提交的反馈意见: 一般 要访问侦听操作,您必须与权限所有者建立适当的关系。但是,我们目前不接受新提交的内容。
我用于此的代码:
public void sendListenTicker(PlayElement a_element) {
if(requestPublishPermissions() == false) {
return;
}
// Create a batch request
RequestBatch requestBatch = new RequestBatch();
// Set up the OpenGraphObject representing the book.
OpenGraphObject song = OpenGraphObject.Factory.createForPost("music.song");
song.setTitle(a_element.titre);
song.setDescription(a_element.artiste);
song.setUrl(a_element.url);
song.setImageUrls(Arrays.asList(a_element.getPochette()));
// Create the request for object creation
// 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) {
Log.d(TAG, "FB error " + error.getErrorMessage());
Log.d(TAG, " - " + error);
Request.Callback objectCallbackDelete = new Request.Callback() {
@Override
public void onCompleted(Response response) {
// Log any response error
FacebookRequestError error = response.getError();
if (error != null) {
Log.d(TAG, "FB error " + error.getErrorMessage());
Log.d(TAG, " - " + error);
}
_radioID = "";
_preferences.edit().putString("RADIO_TICKER_ID", _radioID).commit();
}
};
Request objectDelete = Request.newDeleteObjectRequest(_session, _radioID, objectCallbackDelete);
RequestBatch requestBatchDelete = new RequestBatch();
requestBatchDelete.add(objectDelete);
requestBatchDelete.executeAsync();
}
}
};
Request objectRequest;
if( !_radioID.equalsIgnoreCase("") ) {
song.setId(_radioID);
objectRequest = Request.newUpdateOpenGraphObjectRequest(_session, song, objectCallback);
// Set the batch name so you can refer to the result
// in the follow-on publish action request
objectRequest.setBatchEntryName("objectUpdate");
} else {
objectRequest = Request.newPostOpenGraphObjectRequest(_session, 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);
if( _radioID.equalsIgnoreCase("") ) {
// 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}");
//readAction.setExplicitlyShared(true);
// 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) {
try {
JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
_radioID = graphResponse.getString("id");
_preferences.edit().putString("RADIO_TICKER_ID", _radioID).commit();
} catch (JSONException e) {
Log.d(TAG, "JSON error " + e.getMessage());
}
} else {
Log.d(TAG, "FB error " + error.getErrorMessage());
Log.d(TAG, " - " + error);
}
}
};
// Create the publish action request
Request actionRequest = Request.newPostOpenGraphActionRequest(_session, readAction, actionCallback);
// Add the request to the batch
requestBatch.add(actionRequest);
}
// Execute the batch request
requestBatch.executeAsync();
}
唯一的另一个选择是设置自定义动作类型,如'Play',但我对此解决方案有一些问题,我可以发布对象但是当我想将此对象转换为Facebook自动收报机时,我从Facebook得到了很多错误:
errorCode: 100, errorType: GraphMethodException, errorMessage: Unsupported post request
或
errorMessage: (#100) Only one of reference objects can be specified for type contactios:play.
提前,谢谢你的帮助。
答案 0 :(得分:0)
得到了同样的反馈。
解释是这样的(来自Facebook的开发人员支持工程师):
" music.listen操作目前已列入选定合作伙伴的白名单。我们目前不接受要求列入白名单的请求。如果/当我们发布music.listen时,我们会在我们的博客上宣布它。"
希望它有所帮助。