Friday, March 16, 2012

[YouTube-API] Re: Allow all comments with approval only??

Hello Kent,

Could you capture the HTTP traffic (both request and response,
headers and body) and see what's actually being sent and received by
your API calls? The easiest way to do that would be use a tool like
Wireshark (http://wireshark.org) to capture the HTTP traffic, since
the logging used by the GData client library will only capture
headers.

If you share the log info in this group, please be sure to X out your
developer key and authentication header values so as not to share your
credentials publicly.

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


On Mar 14, 10:30 am, Kent Dodds <m...@kentcdodds.com> wrote:
> Hi Jeff,
> I've tried this for myself and it didn't work. I've posted my issue on
> StackOverflow<http://stackoverflow.com/questions/9703858/how-to-correctly-ytaccessc...>.
> If you could take a look, I would appreciate it. I'm not sure what I'm
> doing wrong.
>
> Actually, if you don't want to take a look on StackOverflow, here's
> everything that's there pasted into here:
>
> I have a video on YouTube which I have uploaded which I wish to change
> yt:accessControls on (particularly comment moderating). I've looked at the
> YouTube API Reference here and here, but I can't seem to get it updating
> properly. Here's my code:
>
> //Strings declared beforehand: appName, developerId, username, password,
> and vidId.
> YouTubeService service = new YouTubeService(appName, developerId);
> service.setUserCredentials(username, password);
>
> String videoEntryUrl =
> "http://gdata.youtube.com/feeds/api/users/default/uploads/" + vidId;
> VideoEntry createdEntry = service.getEntry(new URL(videoEntryUrl),
> VideoEntry.class);
>
> String originalXMLBlob = createdEntry.getXmlBlob().getBlob();
>
> String atomXml = "<?xml version='1.0'?><entry
> xmlns='http://www.w3.org/2005/Atom'
> xmlns:gd='http://schemas.google.com/g/2005'gd:fields='yt:accessControl'
> xmlns:yt='http://gdata.youtube.com/schemas/2007'><yt:accessControl
> action='comment' permission='moderated'/></entry>";
>
> GDataRequest request = service.createPatchRequest(new URL(createdEntry.
> getEditLink().getHref()));
> request.getRequestStream().write(atomXml.getBytes("UTF-8"));
> request.execute();
> createdEntry = service.parseResponseData(request, VideoEntry.class);
>
> String newXMLBlob = createdEntry.getXmlBlob().getBlob().substring(49);
> //The substring(49) is because after you do a service.parseResponseData...
> it attaches a timestamp to the xmlBlob. To properly compare whether these
> are the same in the printlns I substring it.
>
> System.out.println(newXMLBlob.equals(originalXMLBlob));
> System.out.println(originalXMLBlob);
> System.out.println(newXMLBlob);
> createdEntry.update();
> createdEntry.update();
>
> newXMLBlob = createdEntry.getXmlBlob().getBlob().substring(49);
> System.out.println(newXMLBlob.equals(originalXMLBlob));
> System.out.println(originalXMLBlob);
> System.out.println(newXMLBlob);
> System.out.println("Done");
>
> The output is:
>
> true
> <yt:accessControl permission='allowed' action='comment'/><yt:accessControl
> permission='allowed' action='commentVote'/><yt:accessControl permission=
> 'moderated' action='videoRespond'/><yt:accessControl permission='allowed'action
> ='rate'/><yt:accessControl permission='allowed' action='embed'/><yt:accessControl
> permission='allowed' action='list'/><yt:accessControl permission='allowed'action
> ='autoPlay'/><yt:accessControl permission='allowed' action='syndicate'/>
> <yt:accessControl permission='allowed' action='comment'/><yt:accessControl
> permission='allowed' action='commentVote'/><yt:accessControl permission=
> 'moderated' action='videoRespond'/><yt:accessControl permission='allowed'action
> ='rate'/><yt:accessControl permission='allowed' action='embed'/><yt:accessControl
> permission='allowed' action='list'/><yt:accessControl permission='allowed'action
> ='autoPlay'/><yt:accessControl permission='allowed' action='syndicate'/>
> true
> <yt:accessControl permission='allowed' action='comment'/><yt:accessControl
> permission='allowed' action='commentVote'/><yt:accessControl permission=
> 'moderated' action='videoRespond'/><yt:accessControl permission='allowed'action
> ='rate'/><yt:accessControl permission='allowed' action='embed'/><yt:accessControl
> permission='allowed' action='list'/><yt:accessControl permission='allowed'action
> ='autoPlay'/><yt:accessControl permission='allowed' action='syndicate'/>
> <yt:accessControl permission='allowed' action='comment'/><yt:accessControl
> permission='allowed' action='commentVote'/><yt:accessControl permission=
> 'moderated' action='videoRespond'/><yt:accessControl permission='allowed'action
> ='rate'/><yt:accessControl permission='allowed' action='embed'/><yt:accessControl
> permission='allowed' action='list'/><yt:accessControl permission='allowed'action
> ='autoPlay'/><yt:accessControl permission='allowed' action='syndicate'/>
> Done
>
> The important thing is that nothing changed from start to finish. You can
> see I even tried doing createdEntry.update(); but that doesn't work either.
> Any help would be greatly appreciated! Thanks!
>
> Oh, and one last thing. I would like my atomXml to be able to set access
> controls to multiple things (video responses, rating, etc.). I'm guessing
> you just add more yt:accessControl tags, but in answering, if you have any
> tips about that, I would appreciate it. Thanks again.
>
>
>
>
>
>
>
> On Tuesday, August 10, 2010 4:09:24 PM UTC-6, Jeffrey Posnick wrote:
>
> > Hello Hector,
>
> >  What you want to do is add an yt:accessControl element to the video
> > entry, with an action attribute of "comment" and a permission
> > attribute of "moderated". I don't believe that there is native support
> > for the yt:accessControl element in the Java client library yet, so
> > this would have to be done "by hand". Here's some example code that
> > assumes you've just created a new video, and then performs a partial
> > update to set the yt:accessControl value for that video:
>
> >     // ...snip code from the developer's guide for creating a new
> > video...
> >     VideoEntry createdEntry = service.insert(new URL(uploadUrl),
> > newEntry);
>
> >     String atomXml = "<?xml version='1.0'?><entry xmlns='http://
> >www.w3.org/2005/Atom'xmlns:gd='http://schemas.google.com/g/2005'
> > gd:fields='yt:accessControl' xmlns:yt='http://gdata.youtube.com/
> > schemas/2007 <http://gdata.youtube.com/schemas/2007>'><yt:accessControl
> > action='comment'
> > permission='moderated'/></entry>";
> >     GDataRequest request = service.createPatchRequest(new
> > URL(createdEntry.getEditLink().getHref()));
> >     request.getRequestStream().write(atomXml.getBytes("UTF-8"));
> >     request.execute();
> >     createdEntry = service.parseResponseData(request,
> > VideoEntry.class);
> >     // createdEntry now contains the updated VideoEntry, and the
> > access control should be set on it.
>
> > Cheers,
> > -Jeff Posnick, YouTube API Team
> > ~ YouTube is hiring! ~http://google.com/jobs/workyoutube~
>
> > On Aug 10, 3:08 am, Héctor <hector.go...@eltallerdigital.com> wrote:
> > > Hi,
>
> > > Im a Java developer, and beginner in YouTube API. I'd like to upload a
> > > video (I did using youtube samples) and set that all comment of this
> > > video had to be approved. Is it possible to do that with Java API? Can
> > > anybody write down any Java code? Thanks for your 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