I'm trying to share a video url from my device to Facebook. To do so I'm using following code:
GraphRequest request = null;
try {
request = GraphRequest.newPostRequest(
token,
"/me/videos",
new JSONObject("{\"file_url\":\"some url\",\"description\":\"Android upload\"}"),
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
}
});
} catch (JSONException e) {
e.printStackTrace();
}
It is the code generated at Graph Explorer. However, I'm getting an error:
{
"error": {
"message": "There was a problem uploading your video file. Please try again.",
"type": "OAuthException",
"code": 390,
"error_subcode": 1363030,
"is_transient": true,
"error_user_title": "Video Upload Time Out",
"error_user_msg": "Your video upload timed out before it could be completed. This is probably because of a slow network connection or because the video you're trying to upload is too large. Please try again.",
"fbtrace_id": "AxXLWPEDSIF"
}
}
Android Facebook SDK: 4.28.0, 4.31.0
It turns out parameters should be sent directly in the query. So, working code:
Bundle parameters = new Bundle();
parameters.putString("file_url", uri);
parameters.putString("description", comment);
GraphRequest request = new GraphRequest(token, "me/videos", parameters, HttpMethod.POST, callback);
Decided to post this because the error message doesn't get any clue what is going wrong.