You are a life saver and I really appreciate the time you put into getting this to work. It runs like a charm manually so I have set it up in cron to upload the video at midnight, and run your code at 12:30 AM. It does not get the embed code while it is still processing the uploaded video that is why the delay.
This is my third night / early morning trying to get this to work and it is just passed 3:00AM so I am glad it works.
Thank you again
This is my third night / early morning trying to get this to work and it is just passed 3:00AM so I am glad it works.
Thank you again
> Date: Sat, 3 Mar 2012 01:10:19 -0800
> Subject: [YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i
> From: musicsub@live.nl
> To: youtube-api-gdata@googlegroups.com
>
> Hi, i made some PHP code you can try.
> I think you only need to set the correct PATH to your Zend library and
> then it should work.
> Also check the filename that is written to. Without a path it is put
> into the same folder as the scriptfile.
> This code works work for me as it is given here. Here it is:
>
> <?PHP // Mar 3, 2012
>
> // the Zend dir must be in your include_path
> set_include_path('C:/ZendGdata/library');
> require_once 'Zend/Loader.php';
> Zend_Loader::loadClass('Zend_Gdata_YouTube');
>
> $user = 'dingo001';
> echo "Get last video for " . $user . "...\n";
> $feed = GetLastVideoByUser($user);
> if ($feed)
> {
> foreach($feed as $entry)
> {
> $videoId = $entry->getVideoId();
> echo "Create embedded object script for video " . $videoId .
> "...\n";
> FileVideoId($videoId);
> break; // 1 file only
> }
>
> }
>
> echo "Done!\n";
> RETURN;
> // --- end of main ---
>
> function GetLastVideoByUser($user, $maxResults=1)
> { // get last uploaded video from user
> // copied from other application and modified:
> // getTopRatedVideosByUser($user, $maxResults=10, $orderBy='rating',
> $vidFormat=5)
>
> $userVideosUrl = 'http://gdata.youtube.com/feeds/users/' .
> $user . '/uploads';
> $youTubeService = new Zend_Gdata_YouTube();
> $ytQuery = $youTubeService->newVideoQuery($userVideosUrl);
> // retrieve a maximum of videos
> $ytQuery->setMaxResults($maxResults);
> try { $feed = $youTubeService->getVideoFeed($ytQuery); }
> catch (Zend_Gdata_App_HttpException $httpException)
> { echo $httpException->getRawResponseBody();}
> catch (Zend_Gdata_App_Exception $e)
> { echo $e->getMessage();}
> RETURN ($feed);
> } // end of function
>
> function FileVideoId($videoId, $filename="youtube-object.php")
> { // Write $somecontent to our file.
>
> if (!$handle = fopen($filename, 'w'))
> {
> echo "Cannot open file ($filename)";
> RETURN;
> }
> $somecontent = '<center><object width="640" height="505">'
> . '<param name="movie" value="http://www.youtube.com/v/'
> . $videoId
> . '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"></
> param>'
> . '<param name="allowFullScreen" value="true"></param>'
> . '<param name="allowscriptaccess" value="always"></
> param>'
> . '<embed src="http://www.youtube.com/v/'
> . $videoId
> . '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"'
> . ' type="application/x-shockwave-flash"'
> . ' allowscriptaccess="always"'
> . ' allowfullscreen="true"'
> . ' width="640" height="505">'
> . '</embed></object></center>';
>
> if (fwrite($handle, $somecontent) === FALSE)
> {
> echo "Cannot write to file ($filename)";
> RETURN;
> }
> fclose($handle);
> } // end of function
> ?>
>
>
> On 3 mrt, 01:46, Giles AJ <gile...@hotmail.com> wrote:
> > Very easy to say, in reality I am not able to figure it out. I have tried to set options on the router with no luck, posted in the router forum and got no answers. I guess I will just have to live with it if I cannot get the information by other code.
> >
> > Thanks for the replies.
> >
> >
> >
> >
> >
> >
> >
> > > Date: Fri, 2 Mar 2012 06:05:05 -0800
> > > Subject: [YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i
> > > From: music...@live.nl
> > > To: youtube-api-gdata@googlegroups.com
> >
> > > It seems to be a communication problem between the router and the
> > > computer.
> > > I don't think other code will help with this.
> >
> > > On 2 mrt, 14:16, Giles AJ <gile...@hotmail.com> wrote:
> > > > Yes I know it works because each night before 12:00 I change routers to the one that works so the video will load. I am now looking to take the embedding code out of the original and try and make another script to get the embedding code from youtube after the upload script is finished.
> >
> > > > I am not a programmer so I am looking for help on what I would do to get the embedding code or the url from youtube from the information I used to upload the movie and the date because the info is the same every night.
> >
> > > > If you can help that would be great.
> > > > Date: Thu, 1 Mar 2012 22:48:06 -0800
> > > > From: gile...@hotmail.com
> > > > To: youtube-api-gdata@googlegroups.com
> > > > Subject: Re: [YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i
> >
> > > > Hi
> >
> > > > I am not a programmer and I have been looking at the doco to find away around this problem but have come to a dead end.
> >
> > > > I have taken the code out that gets the video ID for the embedding and the upload of the video will work on both routers. I just tested that.
> >
> > > > So my question now is, is there a way in PHP to find the URL or the part of the url that is the VideoId using the information that I used to send the video to YouTube plus maybe the date because the information is the same every day.
> >
> > > >
> >
> > > > Info from video I send:
> >
> > > > echo "Authenticating client...\n";
> >
> > > > > $authenticationURL=
> > > > > 'https://www.google.com/youtube/accounts/ClientLogin';
> > > > > $httpClient =
> > > > > Zend_Gdata_ClientLogin::getHttpClient(
> > > > > $username = 'em...@hotmail.com',
> > > > > $password = 'password',
> > > > > $service = 'youtube',
> > > > > $client = null,
> > > > > $source = 'MySource', // a short string identifying your
> > > > > application
> > > > > $loginToken = null,
> > > > > $loginCaptcha = null,
> > > > > $authenticationURL);
> >
> > > > > $developerKey = 'MY KEY GOES HERE';
> > > > > $applicationId = 'Video uploader v1';
> > > > > $clientId = 'My video upload client - v1';
> >
> > > > The other info as well, the video description etc
> >
> > > > Cheers,
> >
> > > > On Wednesday, February 29, 2012 5:56:39 PM UTC+11, Tim Wintle (Guru) wrote:On Tue, 2012-02-28 at 21:00 -0800, Dingo001 wrote:
> > > > > Here is the code that I am using except for personal info like the
> > > > > developer code etc.Reading this section:try {
> >
> > > > $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl,
> > > > 'Zend_Gdata_YouTube_VideoEntry');} catch (Zend_Gdata_App_HttpException $httpException) {
> >
> > > > echo $httpException->getRawResponseBody();} catch (Zend_Gdata_App_Exception $e) {
> >
> > > > echo $e->getMessage();}if an exception is thrown then $newEntry is never defined - but you then
> >
> > > > assume it's defined later in your code.I'd hunt around that call to find out what's going wrong.Tim Wintle
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "YouTube APIs Developer Forum" group.
> > > > > To view this discussion on the web visit
> > > > >https://groups.google.com/d/msg/youtube-api-gdata/-/NO0VJTeHhsIJ.
> > > > > To post to this group, send email to
> > > > > youtube-api-gdata@googlegroups.com.
> > > > > To unsubscribe from this group, send email to youtube-api-gdata
> > > > > +unsubscribe@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/youtube-api-gdata?hl=en.
> > > > On Wednesday, February 29, 2012 5:56:39 PM UTC+11, Tim Wintle (Guru) wrote:On Tue, 2012-02-28 at 21:00 -0800, Dingo001 wrote:
> > > > > Here is the code that I am using except for personal info like the
> > > > > developer code etc.Reading this section:try {
> >
> > > > $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl,
> > > > 'Zend_Gdata_YouTube_VideoEntry');} catch (Zend_Gdata_App_HttpException $httpException) {
> >
> > > > echo $httpException->getRawResponseBody();} catch (Zend_Gdata_App_Exception $e) {
> >
> > > > echo $e->getMessage();}if an exception is thrown then $newEntry is never defined - but you then
> >
> > > > assume it's defined later in your code.I'd hunt around that call to find out what's going wrong.Tim Wintle>
> >
> > > > > [code=php]
> >
> > > > > set_include_path('/PATH TO/ZendGdata-1.10.1/library');
> > > > > 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_ClientLogin');
> >
> > > > > echo "Authenticating client...\n";
> > > > > $authenticationURL=
> > > > > 'https://www.google.com/youtube/accounts/ClientLogin';
> > > > > $httpClient =
> > > > > Zend_Gdata_ClientLogin::getHttpClient(
> > > > > $username = 'em...@hotmail.com',
> > > > > $password = 'password',
> > > > > $service = 'youtube',
> > > > > $client = null,
> > > > > $source = 'MySource', // a short string identifying your
> > > > > application
> > > > > $loginToken = null,
> > > > > $loginCaptcha = null,
> > > > > $authenticationURL);
> >
> > > > > $developerKey = 'MY KEY GOES HERE';
> > > > > $applicationId = 'Video uploader v1';
> > > > > $clientId = 'My video upload client - v1';
> >
> > > > > echo "Uploading video...\n";
> > > > > $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
> > > > > $developerKey);
> >
> > > > > // create a new VideoEntry object
> > > > > $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
> > > > > // create a new Zend_Gdata_App_MediaFileSource object
> > > > > $filesource = $yt->newMediaFileSource('/PATH
> > > > > TO/webcam2-video-hi.avi');
> > > > > $filesource->setContentType('video/avi');
> > > > > // set slug header
> > > > > $filesource->setSlug('webcam2-video-hi.avi');
> >
> > > > > // add the filesource to the video entry
> > > > > $myVideoEntry->setMediaSource($filesource);
> >
> > > > > $myVideoEntry->setVideoTitle('Albury N.S.W. Australia for ' . date('D,
> > > > > jS F Y', mktime(0, 0, 0, date("m"), date("d")-1)));
> >
> > > > > $myVideoEntry->setVideoDescription('This is a picture of my back yard
> > > > > in Albury NSW Australia. If you look back at older videos you will see
> > > > > them from the coast of NSW and also from Canada.');
> >
> > > > > // The category must be a valid YouTube category!
> > > > > $myVideoEntry->setVideoCategory('Travel');
> >
> > > > > // Set keywords. Please note that this must be a comma-separated
> > > > > string
> > > > > // and that individual keywords cannot contain whitespace
> > > > > $myVideoEntry->SetVideoTags('Albury, NSW, australia, webcam,
> > > > > timelapse, Birds');
> >
> > > > > // 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('-36.07000000000000 146.950000000000');
> > > > > $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');
> > > > > } catch (Zend_Gdata_App_HttpException $httpException) {
> > > > > echo $httpException->getRawResponseBody();
> > > > > } catch (Zend_Gdata_App_Exception $e) {
> > > > > echo $e->getMessage();
> > > > > }
> >
> > > > > echo "Create embedded object script for video...\n";
> > > > > $filename="/PATH/youtube-object.php";
> > > > > if (!$handle = fopen($filename, 'w')) {
> > > > > echo "Cannot open file ($filename)";
> > > > > exit;
> > > > > } // Write $somecontent to our opened file.
> > > > > $somecontent='<center><object width="640" height="505"><param
> > > > > name="movie" value="http://www.youtube.com/v/'.
> > > > > $newEntry->getVideoId() .
> > > > > '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"></param><param
> > > > > name="allowFullScreen" value="true"></param><param
> > > > > name="allowscriptaccess" value="always"></param><embed
> > > > > src="http://www.youtube.com/v/'. $newEntry->getVideoId() .
> > > > > '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"
> > > > > type="application/x-shockwave-flash" allowscriptaccess="always"
> > > > > allowfullscreen="true" width="640"
> > > > > height="505"></embed></object></center>';
> >
> > > > > if (fwrite($handle, $somecontent) === FALSE) {
> > > > > echo "Cannot write to file ($filename)";
> > > > > exit;
> > > > > }
> >
> > > > > fclose($handle);
> > > > > echo "Done!\n";
> >
> > > > > ?>
> > > > > [/code]
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "YouTube APIs Developer Forum" group.
> > > > > To view this discussion on the web visit
> > > > >https://groups.google.com/d/msg/youtube-api-gdata/-/NO0VJTeHhsIJ.
> > > > > To post to this group, send email to
> > > > > youtube-api-gdata@googlegroups.com.
> > > > > To unsubscribe from this group, send email to youtube-api-gdata
> >
> > ...
> >
> > meer lezen »
>
> --
> You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
> To post to this group, send email to youtube-api-gdata@googlegroups.com.
> To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
>
> Subject: [YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i
> From: musicsub@live.nl
> To: youtube-api-gdata@googlegroups.com
>
> Hi, i made some PHP code you can try.
> I think you only need to set the correct PATH to your Zend library and
> then it should work.
> Also check the filename that is written to. Without a path it is put
> into the same folder as the scriptfile.
> This code works work for me as it is given here. Here it is:
>
> <?PHP // Mar 3, 2012
>
> // the Zend dir must be in your include_path
> set_include_path('C:/ZendGdata/library');
> require_once 'Zend/Loader.php';
> Zend_Loader::loadClass('Zend_Gdata_YouTube');
>
> $user = 'dingo001';
> echo "Get last video for " . $user . "...\n";
> $feed = GetLastVideoByUser($user);
> if ($feed)
> {
> foreach($feed as $entry)
> {
> $videoId = $entry->getVideoId();
> echo "Create embedded object script for video " . $videoId .
> "...\n";
> FileVideoId($videoId);
> break; // 1 file only
> }
>
> }
>
> echo "Done!\n";
> RETURN;
> // --- end of main ---
>
> function GetLastVideoByUser($user, $maxResults=1)
> { // get last uploaded video from user
> // copied from other application and modified:
> // getTopRatedVideosByUser($user, $maxResults=10, $orderBy='rating',
> $vidFormat=5)
>
> $userVideosUrl = 'http://gdata.youtube.com/feeds/users/' .
> $user . '/uploads';
> $youTubeService = new Zend_Gdata_YouTube();
> $ytQuery = $youTubeService->newVideoQuery($userVideosUrl);
> // retrieve a maximum of videos
> $ytQuery->setMaxResults($maxResults);
> try { $feed = $youTubeService->getVideoFeed($ytQuery); }
> catch (Zend_Gdata_App_HttpException $httpException)
> { echo $httpException->getRawResponseBody();}
> catch (Zend_Gdata_App_Exception $e)
> { echo $e->getMessage();}
> RETURN ($feed);
> } // end of function
>
> function FileVideoId($videoId, $filename="youtube-object.php")
> { // Write $somecontent to our file.
>
> if (!$handle = fopen($filename, 'w'))
> {
> echo "Cannot open file ($filename)";
> RETURN;
> }
> $somecontent = '<center><object width="640" height="505">'
> . '<param name="movie" value="http://www.youtube.com/v/'
> . $videoId
> . '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"></
> param>'
> . '<param name="allowFullScreen" value="true"></param>'
> . '<param name="allowscriptaccess" value="always"></
> param>'
> . '<embed src="http://www.youtube.com/v/'
> . $videoId
> . '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"'
> . ' type="application/x-shockwave-flash"'
> . ' allowscriptaccess="always"'
> . ' allowfullscreen="true"'
> . ' width="640" height="505">'
> . '</embed></object></center>';
>
> if (fwrite($handle, $somecontent) === FALSE)
> {
> echo "Cannot write to file ($filename)";
> RETURN;
> }
> fclose($handle);
> } // end of function
> ?>
>
>
> On 3 mrt, 01:46, Giles AJ <gile...@hotmail.com> wrote:
> > Very easy to say, in reality I am not able to figure it out. I have tried to set options on the router with no luck, posted in the router forum and got no answers. I guess I will just have to live with it if I cannot get the information by other code.
> >
> > Thanks for the replies.
> >
> >
> >
> >
> >
> >
> >
> > > Date: Fri, 2 Mar 2012 06:05:05 -0800
> > > Subject: [YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i
> > > From: music...@live.nl
> > > To: youtube-api-gdata@googlegroups.com
> >
> > > It seems to be a communication problem between the router and the
> > > computer.
> > > I don't think other code will help with this.
> >
> > > On 2 mrt, 14:16, Giles AJ <gile...@hotmail.com> wrote:
> > > > Yes I know it works because each night before 12:00 I change routers to the one that works so the video will load. I am now looking to take the embedding code out of the original and try and make another script to get the embedding code from youtube after the upload script is finished.
> >
> > > > I am not a programmer so I am looking for help on what I would do to get the embedding code or the url from youtube from the information I used to upload the movie and the date because the info is the same every night.
> >
> > > > If you can help that would be great.
> > > > Date: Thu, 1 Mar 2012 22:48:06 -0800
> > > > From: gile...@hotmail.com
> > > > To: youtube-api-gdata@googlegroups.com
> > > > Subject: Re: [YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i
> >
> > > > Hi
> >
> > > > I am not a programmer and I have been looking at the doco to find away around this problem but have come to a dead end.
> >
> > > > I have taken the code out that gets the video ID for the embedding and the upload of the video will work on both routers. I just tested that.
> >
> > > > So my question now is, is there a way in PHP to find the URL or the part of the url that is the VideoId using the information that I used to send the video to YouTube plus maybe the date because the information is the same every day.
> >
> > > >
> >
> > > > Info from video I send:
> >
> > > > echo "Authenticating client...\n";
> >
> > > > > $authenticationURL=
> > > > > 'https://www.google.com/youtube/accounts/ClientLogin';
> > > > > $httpClient =
> > > > > Zend_Gdata_ClientLogin::getHttpClient(
> > > > > $username = 'em...@hotmail.com',
> > > > > $password = 'password',
> > > > > $service = 'youtube',
> > > > > $client = null,
> > > > > $source = 'MySource', // a short string identifying your
> > > > > application
> > > > > $loginToken = null,
> > > > > $loginCaptcha = null,
> > > > > $authenticationURL);
> >
> > > > > $developerKey = 'MY KEY GOES HERE';
> > > > > $applicationId = 'Video uploader v1';
> > > > > $clientId = 'My video upload client - v1';
> >
> > > > The other info as well, the video description etc
> >
> > > > Cheers,
> >
> > > > On Wednesday, February 29, 2012 5:56:39 PM UTC+11, Tim Wintle (Guru) wrote:On Tue, 2012-02-28 at 21:00 -0800, Dingo001 wrote:
> > > > > Here is the code that I am using except for personal info like the
> > > > > developer code etc.Reading this section:try {
> >
> > > > $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl,
> > > > 'Zend_Gdata_YouTube_VideoEntry');} catch (Zend_Gdata_App_HttpException $httpException) {
> >
> > > > echo $httpException->getRawResponseBody();} catch (Zend_Gdata_App_Exception $e) {
> >
> > > > echo $e->getMessage();}if an exception is thrown then $newEntry is never defined - but you then
> >
> > > > assume it's defined later in your code.I'd hunt around that call to find out what's going wrong.Tim Wintle
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "YouTube APIs Developer Forum" group.
> > > > > To view this discussion on the web visit
> > > > >https://groups.google.com/d/msg/youtube-api-gdata/-/NO0VJTeHhsIJ.
> > > > > To post to this group, send email to
> > > > > youtube-api-gdata@googlegroups.com.
> > > > > To unsubscribe from this group, send email to youtube-api-gdata
> > > > > +unsubscribe@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/youtube-api-gdata?hl=en.
> > > > On Wednesday, February 29, 2012 5:56:39 PM UTC+11, Tim Wintle (Guru) wrote:On Tue, 2012-02-28 at 21:00 -0800, Dingo001 wrote:
> > > > > Here is the code that I am using except for personal info like the
> > > > > developer code etc.Reading this section:try {
> >
> > > > $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl,
> > > > 'Zend_Gdata_YouTube_VideoEntry');} catch (Zend_Gdata_App_HttpException $httpException) {
> >
> > > > echo $httpException->getRawResponseBody();} catch (Zend_Gdata_App_Exception $e) {
> >
> > > > echo $e->getMessage();}if an exception is thrown then $newEntry is never defined - but you then
> >
> > > > assume it's defined later in your code.I'd hunt around that call to find out what's going wrong.Tim Wintle>
> >
> > > > > [code=php]
> >
> > > > > set_include_path('/PATH TO/ZendGdata-1.10.1/library');
> > > > > 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_ClientLogin');
> >
> > > > > echo "Authenticating client...\n";
> > > > > $authenticationURL=
> > > > > 'https://www.google.com/youtube/accounts/ClientLogin';
> > > > > $httpClient =
> > > > > Zend_Gdata_ClientLogin::getHttpClient(
> > > > > $username = 'em...@hotmail.com',
> > > > > $password = 'password',
> > > > > $service = 'youtube',
> > > > > $client = null,
> > > > > $source = 'MySource', // a short string identifying your
> > > > > application
> > > > > $loginToken = null,
> > > > > $loginCaptcha = null,
> > > > > $authenticationURL);
> >
> > > > > $developerKey = 'MY KEY GOES HERE';
> > > > > $applicationId = 'Video uploader v1';
> > > > > $clientId = 'My video upload client - v1';
> >
> > > > > echo "Uploading video...\n";
> > > > > $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
> > > > > $developerKey);
> >
> > > > > // create a new VideoEntry object
> > > > > $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
> > > > > // create a new Zend_Gdata_App_MediaFileSource object
> > > > > $filesource = $yt->newMediaFileSource('/PATH
> > > > > TO/webcam2-video-hi.avi');
> > > > > $filesource->setContentType('video/avi');
> > > > > // set slug header
> > > > > $filesource->setSlug('webcam2-video-hi.avi');
> >
> > > > > // add the filesource to the video entry
> > > > > $myVideoEntry->setMediaSource($filesource);
> >
> > > > > $myVideoEntry->setVideoTitle('Albury N.S.W. Australia for ' . date('D,
> > > > > jS F Y', mktime(0, 0, 0, date("m"), date("d")-1)));
> >
> > > > > $myVideoEntry->setVideoDescription('This is a picture of my back yard
> > > > > in Albury NSW Australia. If you look back at older videos you will see
> > > > > them from the coast of NSW and also from Canada.');
> >
> > > > > // The category must be a valid YouTube category!
> > > > > $myVideoEntry->setVideoCategory('Travel');
> >
> > > > > // Set keywords. Please note that this must be a comma-separated
> > > > > string
> > > > > // and that individual keywords cannot contain whitespace
> > > > > $myVideoEntry->SetVideoTags('Albury, NSW, australia, webcam,
> > > > > timelapse, Birds');
> >
> > > > > // 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('-36.07000000000000 146.950000000000');
> > > > > $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');
> > > > > } catch (Zend_Gdata_App_HttpException $httpException) {
> > > > > echo $httpException->getRawResponseBody();
> > > > > } catch (Zend_Gdata_App_Exception $e) {
> > > > > echo $e->getMessage();
> > > > > }
> >
> > > > > echo "Create embedded object script for video...\n";
> > > > > $filename="/PATH/youtube-object.php";
> > > > > if (!$handle = fopen($filename, 'w')) {
> > > > > echo "Cannot open file ($filename)";
> > > > > exit;
> > > > > } // Write $somecontent to our opened file.
> > > > > $somecontent='<center><object width="640" height="505"><param
> > > > > name="movie" value="http://www.youtube.com/v/'.
> > > > > $newEntry->getVideoId() .
> > > > > '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"></param><param
> > > > > name="allowFullScreen" value="true"></param><param
> > > > > name="allowscriptaccess" value="always"></param><embed
> > > > > src="http://www.youtube.com/v/'. $newEntry->getVideoId() .
> > > > > '&hl=en_GB&fs=1&color1=0x2b405b&color2=0x6b8ab6"
> > > > > type="application/x-shockwave-flash" allowscriptaccess="always"
> > > > > allowfullscreen="true" width="640"
> > > > > height="505"></embed></object></center>';
> >
> > > > > if (fwrite($handle, $somecontent) === FALSE) {
> > > > > echo "Cannot write to file ($filename)";
> > > > > exit;
> > > > > }
> >
> > > > > fclose($handle);
> > > > > echo "Done!\n";
> >
> > > > > ?>
> > > > > [/code]
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "YouTube APIs Developer Forum" group.
> > > > > To view this discussion on the web visit
> > > > >https://groups.google.com/d/msg/youtube-api-gdata/-/NO0VJTeHhsIJ.
> > > > > To post to this group, send email to
> > > > > youtube-api-gdata@googlegroups.com.
> > > > > To unsubscribe from this group, send email to youtube-api-gdata
> >
> > ...
> >
> > meer lezen »
>
> --
> You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
> To post to this group, send email to youtube-api-gdata@googlegroups.com.
> To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
>
No comments:
Post a Comment