Friday, January 20, 2012

[YouTube-API] Re: Using a sessionToken two times

Hello Ludo,

Hmm, could you try calling var_dump($Evideo) after you get the full
video entry and see if there's a link entry with a rel attribute of
"edit"?

In any case, you technically don't have to retrieve the edit link
from the existing entry. You could make use of the fact that the edit
links (currently, at least) are all of the form

https://gdata.youtube.com/feeds/api/users/default/uploads/VIDEO_ID

as documented at

http://code.google.com/apis/youtube/2.0/developers_guide_protocol_updating_and_deleting_videos.html#Updating_Video_Entry

and just construct that URL by hand.

Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev


On Jan 20, 10:33 am, Ludo <ludovic....@gmail.com> wrote:
> I also would say that the code with "userName" (in my view) works, the
> problem is in my controller, where i only use the id (which i get with
> getUploads() in my view and i send to my controller by a form) of the
> video (i am trying to edit them one per one with getVideoEntry()).
>
> On 20 jan, 12:08, Ludo <ludovic....@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi Jeff, thanks for your help !
>
> > indeed, i didn't see this part of the documentation, but unfortunetly,
> > it doesn't works...
>
> > (In my case, "userName" is already "default").
>
> > Let's see what's happening:
> > if ($video->getEditLink() === null)
> >                 {
> >                         echo '<br />null begin<br/>';
> >                         $Evideo = $video->getFullVideoEntry($video_id);
> >                         $putUrl = $Evideo->getEditLink()->getHref();
> >                         $yt->updateEntry($Evideo, $putUrl);
> >                         echo 'null end<br/>';
> >                 }
> >                 else
> >                 {
> >                         echo 'Edition link is existing';
> >                         $putUrl = $video->getEditLink()->getHref();
> >                         $yt->updateEntry($video, $putUrl);
> >                 }
> >                 echo 'OK';
>
> > With this code, the result on my page is:
>
> > OK
> > YInFdh7qoGE
> > null begin
>
> > and nothin...
>
> > On 19 jan, 20:52, Jeffrey Posnick <je...@google.com> wrote:
>
> > > Hello Ludo,
>
> > >  That doesn't sound like an issue with reusing a session token.
> > > (They're meant to be reused, after all.) It might be necessary to call
> > > getFullVideoEntry(video_id) to get an editable version of the video
> > > entry in this scenario; I'm not entirely sure what the PHP library is
> > > doing under the hood, and video entries from the uploads feed are
> > > normally editable, but the docs suggest that it's necessary in at
> > > least some scenarios:
>
> > >  http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Ide...
>
> > >  If you wanted to rule out an expired token completely, try passing in
> > > the string "default" instead of the $userName variable; "default"
> > > should be evaluated to whatever the currently authenticated user is by
> > > the API server.
>
> > > Cheers,
> > > -Jeff Posnick, YouTube API Team
> > > groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
> > > @YouTubeDev
>
> > > On Jan 18, 9:42 am, Ludo <ludovic....@gmail.com> wrote:
>
> > > > Hi, i would like to update some video descriptions. I do it without
> > > > problem on a page where i get a token , but i would like to do that on
> > > > another place (in a controller) but i fail at the moment to exec
> > > > $video->getEditLink()->getHref();.
>
> > > > I think it's because i don't have anymore permission in my controller,
> > > > to do that, i send the sessionToken that i generated previously in my
> > > > view, and i use it again (in my controller).
>
> > > > Apparently this method is not working.
>
> > > > Let's see some code:
>
> > > > In my view (That's work):
> > > > $sessionToken =
> > > > Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
> > > > $httpClient = Zend_Gdata_AuthSub::getHttpClient($sessionToken);
> > > > $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
> > > > $developerKey);
> > > > $videoFeed = $yt->getUserUploads($userName);
>
> > > > foreach($videoFeed as $video)
> > > > {
> > > > $description = $video->getVideoDescription();
> > > > $video-
> > > > >setVideoDescription($description);
>
> > > > $Url = $video->getEditLink()->getHref();
>
> > > > $yt->updateEntry($video,
> > > > $putUrl);
>
> > > > In my controller ($video->getEditLink()->getHref() fail)
> > > > $sessionToken = $_POST['sessionToken'] (this one i used on my view
> > > > just before)
> > > > $httpClient = Zend_Gdata_AuthSub::getHttpClient($sessionToken);
> > > > $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
> > > > $developerKey);
> > > > $videoFeed = $yt->getUserUploads($userName);
>
> > > > foreach($videoFeed as $video)
> > > > {
> > > > $description = $video->getVideoDescription();
> > > > $video-
> > > > >setVideoDescription($description);
>
> > > > $Url = $video->getEditLink()->getHref();    /
> > > > *FAIL*/
> > > > $yt->updateEntry($video, $putUrl);
>
> > > > thanks for help !

--
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