Friday, March 2, 2012

[YouTube-API] Re: PHP Notice: Fatal error: getVideoId() on a non-object i

Hi, i copied your php code to upload a video and replaced the personal
info.

The PHP code works:
my video gets uploaded and i do get the videoId back from youtube. The
ID is written into the file created.

It seems to me, that your new router is not returning information.
Maybe some router or computer setting is wrong. Or some protection
between the computer and this router.

On 2 mrt, 07:48, Dingo001 <gile...@hotmail.com> wrote:
> 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.
>
> http://www.youtube.com/watch?v=1os04sPV-zE
>
> 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
> > > +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,
>
> ...
>
> 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