我有这个代码,登录Facebook后,我想通过Facebook Android SDK v4.13.1将选中的视频上传到Facebook,
问题:
在我看来,响应正常,但视频未显示在测试用户的时间轴中。
代码:
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();
}
}
响应 1:
{Response: responseCode:200, graphObject:{"id":"10150481253673034", "url":"https:\/\/graph-video.facebook.com\/me\/videos"}, error:null}
响应 2:
{Response: responseCode:200, graphObject:null, error:{HTTPStatus:-1,errorCode:-1,errorType:null, errorMessage:"could not construct request body"}}
编辑 1
我创建了一个具有多个权限的新测试用户,例如
- public_profile
- user_friends,
- 电子邮件,
- user_about_me,
- user_actions.video,
- 用户喜欢,
- user_videos,
- publish_pages,
- publish_actions
并上传视频,但仍得到与 响应 1 相同的响应。
编辑 2
我刚刚注意到,对于测试用户,响应与 Response 1 相同,并且具有完全相同的 ID 10150481253673034
最佳答案
您收到了 2 条回复。
响应 1 来自测试用户。即视频分享成功。 -> 因此,您需要使用 Facebook 开发者控制台
提供的测试用户凭据登录 facebook 并 checkin 时间线。如果您在时间线中没有找到它,请在个人资料中查看。你一定会在那里找到它。
Sometimes it doest not shows shared post on timeline due to some privacy settings set in that account.
响应 2 来自另一个帐户。 -> 失败是因为除非 Facebook 批准您的应用程序,否则它将不允许您使用除测试帐户之外的其他帐户共享视频。因此,当您的应用程序将从 Facebook 提交过程中获得 publish_actions
的批准时,您可以使用不同的帐户进行测试。
所以这种情况是可以的。
请参阅 https://developers.facebook.com/docs/opengraph/submission-process提交过程。
关于使用 Android API 的 Android Facebook 视频上传错误 4+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37935485/