Reputation: 28162
So the new facebook 3.0 offers good guides for how to post on wall. But what do you do when it doesn't fly?
I get following response from facebook:
{Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 100, errorType: OAuthException, errorMessage: (#100) Missing message or attachment}, isFromCache:false}
Here is my permission update:
Session session = ParseFacebookUtils.getSession();
if(session != null) {
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
publishStory();
}
PERMISSIONS has following:
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
Here is my publish code which very much (not completely) is copy paste from facebook:
private void publishStory() {
Bundle postParams = new Bundle();
postParams.putString("name", "Test");
postParams.putString("caption", "Another Test");
postParams.putString("description", mEdit.getText().toString());
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject(); //FIXME <-- here we get the error
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(GlobalValues.LOG_TAG,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getActivity()
.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity()
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(ParseFacebookUtils.getSession(), "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
All help is greatly appreciated.
Edit:
Here is a list of my permissions at request time:
[status_update, photo_upload, video_upload, create_note, share_item, publish_stream, publish_actions, basic_info]
Upvotes: 0
Views: 1389
Reputation: 24
Did you check for publish permissions? Code from link you posted checks for permissions before sending request.
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Edit: Try adding message parameter:
Bundle postParams = new Bundle();
postParams.putString("name", "Test");
postParams.putString("caption", "Another Test");
postParams.putString("description", mEdit.getText().toString());
postParams.putString("message", "My message");
Upvotes: 1