Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中在facebook墙上发布视频_Android_Facebook Graph Api - Fatal编程技术网

在android中在facebook墙上发布视频

在android中在facebook墙上发布视频,android,facebook-graph-api,Android,Facebook Graph Api,我只想把这段视频从我的android应用程序上传到facebook墙上。当用户在facebook上点击该视频时,该视频应在线播放。我该怎么做 我的代码: byte[] data = null; String dataPath = "My Video URL here"; String dataMsg = "Your video description here."; Bundle param; facebook = new Facebook(FB_APP_ID); AsyncFacebookRu

我只想把这段视频从我的android应用程序上传到facebook墙上。当用户在facebook上点击该视频时,该视频应在线播放。我该怎么做

我的代码:

byte[] data = null;
String dataPath = "My Video URL here";
String dataMsg = "Your video description here.";
Bundle param;
facebook = new Facebook(FB_APP_ID);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
InputStream is = null;
try {
    is = new FileInputStream(dataPath);
    data = readBytes(is);
    param = new Bundle();
    param.putString("message", dataMsg);
    param.putByteArray("video", data);
    mAsyncRunner.request("me/videos", param, "POST", new fbRequestListener(), null);
}
catch (FileNotFoundException e) {
   e.printStackTrace();
}
catch (IOException e) {
   e.printStackTrace();
}


public byte[] readBytes(InputStream inputStream) throws IOException {
    // This dynamically extends to take the bytes you read.
    ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();

    // This is storage overwritten on each iteration with bytes.
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];

    // We need to know how may bytes were read to write them to the byteBuffer.
    int len = 0;
    while ((len = inputStream.read(buffer)) != -1) {
        byteBuffer.write(buffer, 0, len);
    }

    // And then we can return your byte array.
    return byteBuffer.toByteArray();
}

到目前为止你都做了些什么?我已经添加了我的代码。但是它没有任何错误。是的。没有错误。但是它没有发布URL。我也遇到了同样的问题,但现在我已经解决了。看看我的答案,希望它能帮助你。如果有任何疑问,请告诉我。