I have this code, after logging in to Facebook, I want to upload selected video to Facebook through Facebook Android SDK v4.13.1,
The response looks OK to me, but the video is not showing in the Test User's Timeline.
public void shareVideoFB(String videoPath, final ProgressDialog pd) {
AccessToken accessToken = AccessToken.getCurrentAccessToken();
GraphRequest request = GraphRequest.newPostRequest(accessToken, "https://graph-video.facebook.com/me/videos", null, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
try {
if (pd.isShowing())
pd.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
onFBShareVideoCompleted(response);
}
});
Bundle params = request.getParameters();
try {
byte[] data = readBytes(videoPath);
params.putByteArray("video.mp4", data);
String albumName = "testFBUpload";
params.putString("title", albumName);
params.putString("description", " #SomeTag");
request.setParameters(params);
request.executeAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
{Response: responseCode:200, graphObject:{"id":"10150481253673034", "url":"https:\/\/graph-video.facebook.com\/me\/videos"}, error:null}
{Response: responseCode:200, graphObject:null, error:{HTTPStatus:-1,errorCode:-1,errorType:null, errorMessage:"could not construct request body"}}
I have created a new test user with several permissions like
and upload the video but still getting the same response as Response 1.
I just noticed that for test users the response is same as Response 1 and with the exact Same ID 10150481253673034
The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.
The Facebook SDK is what allows mobile app developers to integrate Facebook within a mobile app. SDK stands for software development kit, and it allows for a website or app to integrate with Facebook seamlessly. Examples of what you can do with Facebook SDK include: Facebook Login functionality. Facebook content ...
You got 2 responses.
Response 1 is from test user.i.e. video is shared successfully. -> So you need to login to facebook using test user's credentials provided from Facebook developer console
and check in timeline. If you don't find it in timeline then check it out in profile. You will definitely find it out there.
Sometimes it doest not shows shared post on timeline due to some privacy settings set in that account.
Response 2 is from another account. -> It is failed because unless Facebook approves your app, it will not allow you to share video using another account except test account. So when you application will get approval of publish_actions
from Facebook submission process then you can test using different accounts.
So it is okay for this case.
Refer https://developers.facebook.com/docs/opengraph/submission-process for submission process.
In the creation of GraphRequest replace graph path https://graph-video.facebook.com/me/videos
by /me/videos
.
GraphRequest request = GraphRequest.newPostRequest(accessToken, "/me/videos", null, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// your code
}
});
Video Upload with Graph API
Graph API Reference: Video
You can publish videos by using the following edges:
/{user-id}/videos
/{event-id}/videos
/{page-id}/videos
/{group-id}/videos
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With