Hi,
This is a group for questions about Google App Engine, not Youtube. You'll
probably have more luck finding a group dedicated to the Youtube API.

-Nick Johnson

On Sat, Oct 10, 2009 at 5:06 AM, Nsource <[email protected]> wrote:

>
> hello everyone, i'm new.
>
> i neet to upload a video to youtube with youtube api.
>
> And my problem is that everytime i open this page it will wait fot
> long long time (more then 3~4 hours). it should be show something
> after uploaded the video but there isn't any output
>
> But when i go to YOUTUBE.COM ,i also see the video which i upload it
> is.
>
> this is my code
>
>
> <?php
>  require_once 'Zend/Loader.php';
>  // the Zend dir must be in your include_path
>  Zend_Loader::loadClass('Zend_Gdata_YouTube');
>  Zend_Loader::loadClass('Zend_Gdata_AuthSub');
>  Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
>
>
> $authenticationURL= 'https://www.google.com/youtube/accounts/
> ClientLogin';
> $httpClient = Zend_Gdata_ClientLogin::getHttpClient(
>                                          $username =
> '[email protected]',
>                                          $password = 'pass1234',
>                                          $service = 'youtube',
>                                          $client = null,
>                                          $source = 'MySource', // a
> short string identifying your application
>                                          $loginToken = null,
>                                          $loginCaptcha = null,
>                                          $authenticationURL);
>
>
>
> $myDeveloperKey = 'AI39si7-1seWd-
>
> crQBVHK_XPwVfcJPCujLFX9bKfdgqMunKO6xk9Ow0cLLSuA6XLQGlMDT_yoN6Vin9iY8YJISUkC7RLpUWdFg';
>
>
>
> //
> $httpClient->setHeaders('X-GData-Key', "key={$myDeveloperKey}");
> $yt = new Zend_Gdata_YouTube($httpClient);
>
>
> function printVideoFeed($videoFeed, $displayTitle = null)
> {
>  $count = 1;
>  if ($displayTitle === null) {
>    $displayTitle = $videoFeed->title->text;
>  }
>  echo '<h2>' . $displayTitle . "</h2>\n";
>  echo "<pre>\n";
>  foreach ($videoFeed as $videoEntry) {
>    echo 'Entry # ' . $count . "\n";
>    printVideoEntry($videoEntry);
>    echo "\n";
>    $count++;
>  }
>  echo "</pre>\n";
> }
> function printVideoEntry($videoEntry)
> {
>  // the videoEntry object contains many helper functions
>  // that access the underlying mediaGroup object
>  echo 'Video: ' . $videoEntry->getVideoTitle() . "\n";
>  echo 'Video ID: ' . $videoEntry->getVideoId() . "\n";
>  echo 'Updated: ' . $videoEntry->getUpdated() . "\n";
>  echo 'Description: ' . $videoEntry->getVideoDescription() . "\n";
>  echo 'Category: ' . $videoEntry->getVideoCategory() . "\n";
>  echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "\n";
>  echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "\n";
>  echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "\n";
>  echo 'Duration: ' . $videoEntry->getVideoDuration() . "\n";
>  echo 'View count: ' . $videoEntry->getVideoViewCount() . "\n";
>  echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "\n";
>  echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "\n";
>  echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "\n";
>
>  // see the paragraph above this function for more information on
> the
>  // 'mediaGroup' object. in the following code, we use the mediaGroup
>  // object directly to retrieve its 'Mobile RSTP link' child
>  foreach ($videoEntry->mediaGroup->content as $content) {
>    if ($content->type === "video/3gpp") {
>      echo 'Mobile RTSP link: ' . $content->url . "\n";
>    }
>  }
>
>  echo "Thumbnails:\n";
>  $videoThumbnails = $videoEntry->getVideoThumbnails();
>
>  foreach($videoThumbnails as $videoThumbnail) {
>    echo $videoThumbnail['time'] . ' - ' . $videoThumbnail['url'];
>    echo ' height=' . $videoThumbnail['height'];
>    echo ' width=' . $videoThumbnail['width'] . "\n";
>  }
> }
> //printVideoFeed($yt->getuserUploads('default'));
> //exit();
> // create a new VideoEntry object
> $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
> // create a new Zend_Gdata_App_MediaFileSource object
> $filesource = $yt->newMediaFileSource('cc.avi');
> $filesource->setContentType('video/avi');
> // set slug header
> $filesource->setSlug('cc.avi');
> // add the filesource to the video entry
> $myVideoEntry->setMediaSource($filesource);
> $myVideoEntry->setVideoTitle('My Test Movie');
> $myVideoEntry->setVideoDescription('My Test Movie');
> // The category must be a valid YouTube category!
> $myVideoEntry->setVideoCategory('Autos');
> // Set keywords. Please note that this must be a comma-separated
> string
> // and that individual keywords cannot contain whitespace
> $myVideoEntry->SetVideoTags('cars, funny');
> // set some developer tags -- this is optional
> // (see Searching by Developer Tags for more details)
> $myVideoEntry->setVideoDeveloperTags(array('mydevtag',
> 'anotherdevtag'));
> // set the video's location -- this is also optional
> $yt->registerPackage('Zend_Gdata_Geo');
> $yt->registerPackage('Zend_Gdata_Geo_Extension');
> $where = $yt->newGeoRssWhere();
> $position = $yt->newGmlPos('37.0 -122.0');
> $where->point = $yt->newGmlPoint($position);
> $myVideoEntry->setWhere($where);
> // upload URI for the currently authenticated user
> $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/
> uploads';
> // try to upload the video, catching a Zend_Gdata_App_HttpException,
> // if available, or just a regular Zend_Gdata_App_Exception otherwise
>
> try {
>        $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl,
> 'Zend_Gdata_YouTube_VideoEntry');
>        echo 'ok';
>        $state = $videoEntry->getVideoState();
>        if ($state) {
>          echo 'Upload status for video ID ' . $videoEntry->getVideoId() . '
> is ' .
>                $state->getName() . ' - ' . $state->getText() . "\n";
>          } else {
>                echo "Not able to retrieve the video status information yet.
> " .
>                  "Please try again later.\n";
>        }
> } catch (Zend_Gdata_App_HttpException $httpException) {
>        echo $httpException->getRawResponseBody();
> } catch (Zend_Gdata_App_Exception $e) {
>        echo $e->getMessage();
> }
> echo 'pppp';
>
> >
>


-- 
Nick Johnson, Developer Programs Engineer, App Engine
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to