Retrieving progress of Direct Upload using youtube gdata API

前端 未结 1 768
刺人心
刺人心 2021-01-20 20:54

I\'m following along with the documentation about using the gData Youtube API for doing direct uploads with PHP. I can successfully upload videos, so thats all well and goo

1条回答
  •  长发绾君心
    2021-01-20 21:29

    Demo url:--

    http://jquery.malsup.com/form/progress.html

    You can download jquery file below url and add in html tag

    http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js

    http://malsup.github.com/jquery.form.js

    Try this:--

    output video:-

    enter image description here

    This is my video.php file

    
    
    File Upload Progress Demo #1
    
    
    
        

    File Upload Progress Demo #1

    <input type="file" name="myfile">

    0%

    this is my video_upload.php file

    setVideoTitle($videoTitle);
    $myVideoEntry->setVideoDescription($VideoDescription);
    // The category must be a valid YouTube category!
    $myVideoEntry->setVideoCategory($VideoCategory);
    
    // Set keywords. Please note that this must be a comma-separated string
    // and that individual keywords cannot contain whitespace
    $myVideoEntry->SetVideoTags($VideoTags);
    
    $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
    $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
    $tokenValue = $tokenArray['token'];
    $postUrl = $tokenArray['url'];
    
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $postUrl."?nexturl=http://YOUR_WEBPAGE.com/");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    // same as 
    $post = array("file"=>"@".$VideoFile['tmp_name'], "token"=>$tokenValue);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
    $response = curl_exec($ch);
    $info = curl_getinfo($ch);
    
    echo $info;
    
    ?>
    

    0 讨论(0)
提交回复
热议问题