无论我想在Facebook上传视频。 Facebook将在回复时给出以下错误。
响应:responseCode:400,graphObject:null,错误:{HttpStatus:400,错误
Code: 100, subErrorCode: -1, errorType: OAuthException, errorMessage: (#100) No permission to publish the video}}
private void PostVideo(byte[] VideoBytes, String path) {
String url;
url = "/me/videos";
final ProgressDialog dialog = ProgressDialog.show(getContext(), "Loading data", "Please wait", false, false);
AccessToken token = AccessToken.getCurrentAccessToken();
if (token != null) {
Bundle param = new Bundle();
param.putByteArray("video." + getFileExt(path), VideoBytes);
param.putString("description", title+"\n"+description);
new GraphRequest(token,url, param, HttpMethod.POST, new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.e("New Post", "Res =" + response.toString());
dialog.dismiss();
if (response != null && response.getJSONObject() != null && response.getJSONObject().has("id")) {
Log.e("New Post", "Success");
edittext_title.setText("");
edittext_description.setText("");
// getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
Toast.makeText(getContext(), "Video posted successfully.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getContext(), "Error in posting Video.", Toast.LENGTH_SHORT).show();
}
}
}).executeAsync();
}
}
答案 0 :(得分:0)
是的,为此您必须申请video_upload权限。首先,在下面的代码中调用以获得权限。
Session session = Session.getActiveSession();
//If the session is open
if(session.isOpened()) {
//Get the list of permissions associated with the session
List<String> permissions = session.getPermissions();
//if the session does not have video_upload permission
if(!permissions.contains("video_upload")) {
//Get the permission from user to upload the video to facebook
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, Arrays.asList("video_upload"));
session.requestNewReadPermissions(newPermissionsRequest);
}
}
我希望这对你有用。