Reputation: 115212
I'm trying to post image on my wall via my app. It's working well with http links, but I need to post post image from my local phone memory.
File photo = new File(Environment.getExternalStorageDirectory(), "photo.jpeg");
Bundle bundle = new Bundle();
bundle.putString("caption", "test");
bundle.putString("url", photo.toURI().toString());
if ( AccessToken.getCurrentAccessToken()!=null) {
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/<user_id>/photos", bundle,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.i("<<FB=====>>", response.toString());
}
}
).executeAsync();
}
But it's not working getting the following response
{Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 324, errorType: OAuthException, errorMessage: (#324) Missing or invalid image file}}
Now how can I attach a file ?
Upvotes: 0
Views: 208
Reputation: 15662
If you're uploading from local memory, passing in the uri is not enough. You should use the newUploadPhotoRequest(AccessToken, String, File, String, Bundle, Callback)
method in the GraphRequest class.
Upvotes: 1