Friday, September 23, 2011

[YouTube-API] Re: How to add comment to youtube with GDate api?

I use someting like this:


$authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin';

                $httpClient
=
                   
Zend_Gdata_ClientLogin::getHttpClient(
                        $login
,
                        $passwd
,
                        $service
= 'youtube',
                        $client
= null,
                        $source
= 'thingy', // a short string identifying your application
                        $loginToken
= null,
                        $loginCaptcha
= null,
                        $authenticationURL
                   
);

// get your dev key from google
        $developerKey
= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
        $applicationId
= 'thingy';
        $clientId
= 'thingyClient';


$yt
= new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);

        $newComment
= $yt->newCommentEntry();
        $newComment
->content = $yt->newContent()->setText($text); // se yer text here

 
// create a new link element if you're replying to semobody

        $inReplyToLinkHref
= Zend_Gdata_YouTube::VIDEO_URI . '/' . $_videoId . '/comments/' . $_commentId;
        $inReplyToLink
= $yt->newLink($inReplyToLinkHref, Zend_Gdata_YouTube::IN_REPLY_TO_SCHEME, $type="application/atom+xml");

// add to links
        $links
= $newComment->getLink();
        $links
[] = $inReplyToLink;
        $newComment
->setLink($links);


        $commentFeedPostUrl
= Zend_Gdata_YouTube::VIDEO_URI . '/' . $_videoId . '/comments';
$yt
->insertEntry($newComment, $commentFeedPostUrl, 'Zend_Gdata_YouTube_CommentEntry');


--
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/-/H0fJQnmj0lIJ.
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.

1 comment:

  1. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. google contact sharing

    ReplyDelete