Can I use the Youtube API to write comments? - youtube-api

Can I use the Youtube API to write comments? If yes, please provide an example request.

As per the documentation, there are two endpoints that you can use: Comments and CommentThreads, depending on whether your comment is a reply to an existing one, or, otherwise, is a top-level comment (i.e. one that starts a new thread). The reference docs also provide examples attached.

Related

specify recipient Youtube api v3 insert comment

On youtube when I tap Reply button under a non top level comment, the recipient user gets mentioned at the start of the message #Philip .... How can I replicate this behavior with an api v3? My main goal is to notify the reply owner.
I've tried specifying parentId, but it looks like only top level comment can be passed into this property.
Also I've tried specifying #Philip and #CHANNEL_ID at the message start - it doesn't creates a link.
I've inspected commenting in Chrome, and it sends "create_comment_reply" request, which seems like private api😞
Mentions are only for replies to comments in a top-level comment.
Youtube Data API v3 only supports replies to top-level comment. One cannot currently comment to a comment to top-level comment using the API.
In the docs for parameters for comments/list, they note that:
Note: YouTube currently supports replies only for top-level comments. However, replies to replies may be supported in the future.
When comments are supported for comments to top-level comments, it may be possible to perform mentions.

Youtube Data API v3: commentThread call doesn't give replies for some comment threads

I have a problem with commentThread API call. Here is one specific case: comment id: z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k
https://www.googleapis.com/youtube/v3/commentThreads?id=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&part=snippet%2C+replies&key={YOUR_DEVELOPER_KEY}&alt=json&order=time
There are 44 replies for now.
But if you use video_id (not comment id like we did above. Link: https://www.googleapis.com/youtube/v3/commentThreads?videoId=Ui-ulCWmpOU&maxResults=100&pageToken=ChYQp7fipbfsxgIYkNGqiobjxQIgACgDEhQIABCQ0aqKhuPFAhiMqqKive-5AhgCIKwC&part=snippet%2C+replies&key={YOUR_DEVELOPER_KEY}&alt=json&order=time) and come across the comment (you may have to use pageToken to iterate over pages) you will see this:
(Screenshot: https://www.dropbox.com/s/d4bf9tk51eaw7dr/Screenshot%202015-07-21%2021.08.31.png?dl=0)
As you noticed; there is 39 replies (comments) which is not true. And even if we have replies; there is no replies section. Am I missing something?
Two questions: Why number of replies don't match? Why that commentThread doesn't have replies even it has 39 replies?
Notes: As part I am using 'snippet, replies'. I don't get any API error (like throttle or limit violation)
From the commentThreads documentation:
The commentThread resource does not necessarily contain all replies to
a comment, and you need to use the comments.list method if you want to
retrieve all replies for a particular comment.
Use the comments.list call instead and specify the commentThread's ID for the parentId.
When I do the following call:
https://www.googleapis.com/youtube/v3/comments?part=snippet,id&parentId=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&key=[API_KEY_HERE]&order=time&maxResults=50
I get all (44) of the responses to the comment thread you mentioned.
To address your questions:
Why number of replies don't match?
If I had to guess, I'd say it might be due to how the API differentiates between comments and comment threads (where it considers replies to other replies in a thread as opposed to them being associated with the video itself). Since the documentation says that the commentThread resource might not contain all replies to a comment, I think this is still working as intended. At any rate, in the future it's generally better to just go with the higher number of replies reported, since it's more likely that the API is missing some results than reporting extra results. Also, remember that you should be using comments.list if you want all of the replies to a certain comment thread.
Why that commentThread doesn't have replies even it has 39 replies?
To be honest, I'm not sure if it's a YouTube thing or a G+ thing. When I looked at some of the other comment threads that had replies, I was able to see them via the API call when video ID is specified. However, as Daniel mentioned, you can't actually see the replies for the thread you specified on the video itself (but you can see them when you go to that user's G+ page). It's possible that user did something to their G+ settings regarding comments on their shared posts, which is why they aren't showing up on the video itself and thus not showing up in the commentThreads list request. It's hard to say unless you talked to someone who's familiar with G+/YouTube integration.
While I wasn't able to answer your questions definitely, I was able to find some useful info that may give you some clarity and direction.
With regard to the specific case outlined in your question: the user "authorDisplayName": "Tammy L." commented on the video "videoId": "Ui-ulCWmpOU" on 11/16/2013, and received replies between 11/16/2013 and 11/18/2013. According to Tammy L.'s record on Google+, there are 44 replies to her initial comment from this date:
Although, according to the record on YouTube, it appears that there are 42 replies to her comment, which doesn't match either value returned from your API calls. Even more bizarre, Google won't display the comments when I click on "View all 42 replies":
It seems that the commentId call provides the correct number of replies made to Tammy L.'s initial comment, which is consistent with the number of replies shown on her Google+ account. Perhaps the issues with the videoId call (including the fact that this call doesn't provide replies) are attributable to the changes Google implemented around the time that Tammy L. made her initial comment (November 2013), although I'm not totally sure.

YouTube safe search and rating via API

YouTube API v2 allows you to a) search for safeSearch only and b) get the media rating (eg PG-13) https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating .
Is there a way to do this in the v3 API?
If not: Why was this omitted? Are there plans to remove it from v2?
In general, what's the best way using the API to tell if a video is safe?
You should be able to use the safeSearch parameter as described at the following link:
https://developers.google.com/youtube/v3/docs/search/list
I hope that answers the first half of your question.
Furthermore, you can find the getRating method at
https://developers.google.com/youtube/v3/docs/videos/getRating
under the list of video methods (this section also lists the various ratings such as pg13 etc):
https://developers.google.com/youtube/v3/docs/videos

twitter API response : possibly_sensitive content

referring to this link https://dev.twitter.com/discussions/700
Anybody observed possibly_sensitive boolean flag in twitter "search" apis.
Till now I was unable to see this flag, we need to have this data badly to avoid unwanted stuff to show up on our site.
I don't believe Twitter currently adds the field for the search API. You may also note that the search API also does not return results for "popular" tweets, which could also expunge some of the more objectionable content (unless it had become popular). Love to hear other's input on this topic. Thanks!
There is an option to achieve this, use filter:safe
Refer the API here : https://dev.twitter.com/rest/public/search

How to get (scrape) the contents of a site that requires logging in through YQL?

Is it possible to get (scrape) data from a site that requires logging in using YQL? If yes, please tell the procedure.
You'll need the user to authorize your access via OAuth, as YQL's docs mention. In addition to the docs pointed to by links from the URL I just mentioned, you can learn all about OAuth here, then get libraries to help you use OAuth, depending of course on the programming language you want to use, from the links listed here.
Depending on how the remote site is set up, you could use a simple POST (there is an open data table for that1) or you could create your own small, custom data table and use <execute>2 to send whatever headers (including Cookie:) you need over one or more GET/POST requests.
htmlpost data table (example)
YQL Execute

Resources