{
Request request = null;
RequestAsyncTask task = null ;
Bundle requestParams requestParams=new Bundle();
byte[] data = downloadUrl(new URL("urltodownload"));
requestParams.putByteArray("video", data);
requestParams.putString("title", "Video post");
requestParams.putString("description", " #SomeTag");
request = new Request(Session.getActiveSession(),"me/videos" , requestParams,
HttpMethod.POST,new Request.Callback() {
@Override
public void onCompleted(Response response) {
//appLink=null;
if (response.getError() == null) {
Logs.e(DEBUG_FACEBOOK_PUBLISH, "publish success");
if (uploadListener != null) {
uploadListener.onSuccess(null);
}
} else {
Logs.e(DEBUG_FACEBOOK_PUBLISH, "publish error: "
+ response.getError().getErrorMessage());
Logs.e(DEBUG_FACEBOOK_PUBLISH, "publish error: "
+ response.getError().toString());
if (uploadListener != null) {
uploadListener
.onError("Facebook can't publish your content");
}
}
}
});
task = new RequestAsyncTask(request);
task.execute();
}
private static byte[] downloadUrl(URL toDownload) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
byte[] chunk = new byte[4096];
int bytesRead;
InputStream stream = toDownload.openStream();
while ((bytesRead = stream.read(chunk)) > 0) {
outputStream.write(chunk, 0, bytesRead);
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
return outputStream.toByteArray();
}
{HttpStatus:500,errorCode:352,errorType:FacebookApiException, errorMessage:抱歉,您选择的视频文件格式为 我们不支持。}
我不知道自己做错了什么,但每次遇到这个错误。有没有其他方法发布视频到Facebook墙。 我知道如何发布视频 newUploadVideoRequest 方法但在我的情况下我不想下载视频并将其保存到SD卡然后发布到Facebook。 还有其他方式我可以调用图形api url并将视频发布到Facebook墙上但是 有没有其他任何方法,所以我可以直接将视频发布到脸谱墙,我几乎每个链接都参考
答案 0 :(得分:3)
我只是改变了
requestParams.putByteArray(“video”,data); to requestParams.putByteArray(“video.3gp”,data);
它上传成功你可以尝试.mp4也很奇怪,但是没有关于应该传递参数的有用文档。希望这是有帮助的