如何使用android上的opengraph在facebook上发布股票代码,而不使用;“音乐。聆听”;定义标记
我试图在Android上用OpenGraph在Facebook上发布ticker,我在第一次发布时使用了定义的动作类型“Listen”(由Facebook设置),但这一类型只能由Facebook合作伙伴使用: 您最近提交的反馈: 一般的 要访问侦听操作,您必须与权限所有者建立适当的关系。但是,我们目前不接受新的提交。 我为此使用的代码:如何使用android上的opengraph在facebook上发布股票代码,而不使用;“音乐。聆听”;定义标记,android,facebook,facebook-graph-api,facebook-opengraph,ticker,Android,Facebook,Facebook Graph Api,Facebook Opengraph,Ticker,我试图在Android上用OpenGraph在Facebook上发布ticker,我在第一次发布时使用了定义的动作类型“Listen”(由Facebook设置),但这一类型只能由Facebook合作伙伴使用: 您最近提交的反馈: 一般的 要访问侦听操作,您必须与权限所有者建立适当的关系。但是,我们目前不接受新的提交。 我为此使用的代码: public void sendListenTicker(PlayElement a_element) { if(requestPublishPerm
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();
}
唯一的其他选择是设置自定义动作类型,如“播放”,但我对此解决方案有一些问题,我可以发布对象,但当我想将此对象转换为Facebook股票代码时,我从Facebook得到了很多错误:
errorCode: 100, errorType: GraphMethodException, errorMessage: Unsupported post request
或
提前感谢您的帮助。得到了同样的反馈 解释如下(来自Facebook的开发人员支持工程师): “music.listen操作当前已被选定合作伙伴列入白名单。我们目前不接受被列入白名单的请求。如果/当我们发布music.listen时,我们将在我们的博客上宣布。” 希望能有帮助
errorMessage: (#100) Only one of reference objects can be specified for type contactios:play.