我的应用程序:
用户可以将视频上传到他/她的时间轴,并在我的应用程序中显示已发布帖子的类似数据,为此我需要已上传帖子的post_id。
视频完全可以正常上传,但是一旦我在facebook的ShareDialog上点击“共享”按钮,它就会在视频上传完成之前将控制权返回给回调方法的onSuccess。另外,result.getPostId()始终为null。
需要帮助:
这是将视频上传到Facebook的代码:
public void shareVideoOnFacebook(Uri VideoUri , final String FileId) {
try {
FacebookCallback<Sharer.Result> shareCallback = new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
result.getPostId(); //It is always null.
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
};
shareDialog = new ShareDialog(activity);
callbackManager = CallbackManager.Factory.create();
shareDialog.registerCallback(callbackManager , shareCallback);
AccessToken accessToken = AccessToken.getCurrentAccessToken();
boolean isLoggedIn = accessToken != null && !accessToken.isExpired();
if (isLoggedIn) {
ShareVideo video = new ShareVideo.Builder().setLocalUrl(VideoUri).build();
ShareVideoContent content = new ShareVideoContent.Builder().setVideo(video).setPageId(FileId).build();
shareDialog.show(content , ShareDialog.Mode.AUTOMATIC);
}
} catch (Exception ex) {
ex.getMessage();
}
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}