Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.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
Php Facebook视频API未上传视频_Php_Facebook_Facebook Graph Api - Fatal编程技术网

Php Facebook视频API未上传视频

Php Facebook视频API未上传视频,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,它像应该的那样认证并重定向到thankyou.com,但我的时间表上从来没有发布过视频。视频位于www.mydomain.com/video.mp4 <?php $app_id = "2363xxxxxxx"; $app_secret = "e4cd5bbxxxxxxxxxxxxxxx"; $my_url = "http://thankyou.com"; $video_title = "Test"; $video_desc = "Test"; $code = $_REQUE

它像应该的那样认证并重定向到thankyou.com,但我的时间表上从来没有发布过视频。视频位于
www.mydomain.com/video.mp4

 <?php
 $app_id = "2363xxxxxxx";
 $app_secret = "e4cd5bbxxxxxxxxxxxxxxx";
 $my_url = "http://thankyou.com";
 $video_title = "Test";
 $video_desc = "Test";

 $code = $_REQUEST["code"];

 if(empty($code)) {
 $dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
 . $app_id . "&redirect_uri=" . urlencode($my_url)
 . "&scope=publish_stream";
 echo("<script>top.location.href='" . $dialog_url . "'</script>");
 }

 $token_url = "https://graph.facebook.com/oauth/access_token?client_id="
 . $app_id . "&redirect_uri=" . urlencode($my_url)
 . "&client_secret=" . $app_secret
 . "&code=" . $code;
 $access_token = file_get_contents($token_url);

 $post_url = "https://graph-video.facebook.com/me/videos?"
 . "title=" . $video_title. "&description=" . $video_desc
 . "&". $access_token;

//CURL CODES START

    $ch = curl_init();
    $data = array('name' => 'file', 'file' => '@'.realpath("video.mp4"));// use realpath
    curl_setopt($ch, CURLOPT_URL, $post_url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $res = curl_exec($ch);

    if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
        curl_setopt($ch, CURLOPT_CAINFO,
                  dirname(__FILE__) . '/src/fb_ca_chain_bundle.crt'); // path to the certificate
        $res = curl_exec($ch);
    }

    if( $res === false ) {
        echo curl_error($ch);
    }
    curl_close($ch);

//CURL ENDS
?>

您会得到什么样的响应?当您尝试通过API访问返回的对象ID时,返回的对象ID是否有效?