上传视频到fb无法从Android应用程序工作

时间:2014-10-06 06:56:07

标签: android facebook publish-actions

我正在尝试使用以下代码

从我的Android应用上传视频到Facebook
    String dataPath = videoPath;
    File mFile = new File(videoPath);
        if(nDialog==null){
            nDialog = new ProgressDialog(mContext);
        }
        if(!nDialog.isShowing()){
            nDialog.setMessage("Posting to your wall...");
            nDialog.setCancelable(false);
            nDialog.show();
        }
        Request.newUploadVideoRequest(session, mFile,new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                Toast.makeText(mContext,"response"+response,Toast.LENGTH_LONG).show();
                Log.i("Upload video test0",response.toString());
                nDialog.dismiss();
            }
        });

但问题是onCompleted方法永远不会被调用。 我也尝试了其他代码,但这也没有用。请检查Link。 提前谢谢。

编辑:

当我调用newUploadVideoRequest方法时,facebook会话具有以下值 -

{Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[public_profile, email, contact_email, publish_actions]}, appId:xxxxxxxxxxxxxxxxx}

编辑: OnActivity结果:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data);

}

我试过这个link但是onCompleted方法返回 - oauthexception code 2500,OAuthException : An active access token must be require

1 个答案:

答案 0 :(得分:1)

您需要publish_actions权限才能上传视频。

您也只是创建请求,但从不执行它。您需要在代码中添加executeAsync():

 Request.newUploadVideoRequest(session, mFile,new Request.Callback() {
     @Override
     public void onCompleted(Response response) {
         Toast.makeText(mContext,"response"+response,Toast.LENGTH_LONG).show();
         Log.i("Upload video test0",response.toString());
         nDialog.dismiss();
     }
 }).executeAsync();