PHP:使用curl链接[直接链接]将视频上传到youtube

时间:2013-08-13 10:44:07

标签: codeigniter curl youtube

如果我使用下面的表单,视频会上传到youtube。我可以在登录后从youtube获取响应并采用下面的表单中的响应。

 <form action="<?php echo( $response->url ); ?>?nexturl=<?php echo( urlencode( $nexturl ) ); ?>" method="post" enctype="multipart/form-data">
        <p class="block">
            <label>Upload Video</label>
            <span class="youtube-input">
                <input id="file" type="file" name="file" />
            </span>                        
        </p>
        <input type="hidden" name="token" value="<?php echo( $response->token ); ?>"/>
        <input type="submit" value="Upload Video" />
    </form>

但是如果尝试用curl做同样的事情那么它就不起作用..任何建议??

$file_name_with_full_path = $video_path; //$video_path is like /path/to/abc.mp4
$post = array('file'=>'@'.$file_name_with_full_path, 'token' => $response->token,);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$response->url."?nexturl=".urlencode($nexturl));
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
curl_close ($ch);
echo $result;
die();

给出bool的回声结果(false)。请告诉我这里有什么不对。提前谢谢。

0 个答案:

没有答案
相关问题