I'm trying to post tickers on Facebook with open graph on Android, I used at 1st the defined action types 'Listen' (set by Facebook), but this one can only be used by Facebook partners :
Feedback from your most recent submission: General To access the listen action, you must have the appropriate relationships in place with rights owners. However, we're not currently accepting new submissions.
code I used for this :
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();
}
The only other option is to set a custom action types like 'Play' but I have some problem with this solution, I can post object but when I want to transform this object into a Facebook ticker I got lot of error from Facebook :
errorCode: 100, errorType: GraphMethodException, errorMessage: Unsupported post request
or
errorMessage: (#100) Only one of reference objects can be specified for type contactios:play.
By advance, thanks for your help.
Got the same feedback.
The explanation is this ( from a Developer Support Engineer at Facebook ):
"The music.listen action is currently whitelisted for selected partners. We aren't accepting requests to be whitelisted at this time. If/when we release music.listen we'll announce it on our blog."
Hope it helps.