Youtube Livechat API is not finding the live chat - youtube-api

So I was trying to use the LiveChat API from youtube, At the end I got into using this post:
https://www.googleapis.com/youtube/v3/liveChat/messages?access_token=MYACCESSTOKENHERE&part=snippet&messageText=lalala&liveChatId=0bksQfFVZW4
Now it tells me that it can't find the liveChatId, Any reason why?

liveChatId property is associated with liveBroadcast. So try making calls to any of the liveBroadcast methods . A successful response includes the liveChatId property. Don't forget to specify 'snippet' as the 'part' parameter. Also, you'll be required to use OAuth Authorization when calling these methods.

Related

Add reaction to existing posts or comments

How can we "like" or add other reactions to someone else's channel message or comment via the Graph API?
I've not done this myself, but it certainly looks possible. You need to reply to the message, as per https://learn.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-1.0&tabs=http and notice that it has a "reactions" collection. That would be populated with a chatMessageReaction type, as per https://learn.microsoft.com/en-us/graph/api/resources/chatmessagereaction?view=graph-rest-beta
Note of warning: chatMessageReaction is a beta type though, so just be aware you need to call the beta endpoint, and it has a risk to use in production code as things might change.
Update: We reached out to MS Support and received the following info: "The API to reply to a message using a POST /replies request is solemnly for issuing a reply to a message, and not to edit the status of the parent message itself. Moreover, the "update chatMessage" API which is a PATCH /messages and which is the only API to edit a parent message only supports updating the policyViolation property of a chatMessage. Essentially, there is currently no documented API / already-present API examples on how to add a reaction, making this purely unsupported."

Youtube api not returning my live stream

I have created a new google account, then I have enabled youtube live streaming and started to stream. I have app key and access token for my user, but http get request to https://www.googleapis.com/youtube/v3/liveStreams?part=snippet&access_token=MY_TOKEN&key=MY_KEY&mine=true is returning zero results, meanwhile at the moment I have live stream.
What to do?
Try using LiveStreams.list instead. It returns a list of video streams that match the API request parameters. There's an example for your code reference.
I found the saving clue in this SO answer. To receive the list, one has to explicitly provide the broadcastType parameter to the query.
Acceptable values are:
all – Return all broadcasts.
event – Return only scheduled event broadcasts.
persistent – Return only persistent broadcasts.
If you find this answer useful, please make sure to upvote the linked answer (as well). I just copy-pasted this.

Getting direct messages using Twitter REST api

I'm experimenting with twitter REST API with Ruby on Rails.
I'm using twitter gem for the same. I could get the client object using in my code.
client = current_domain.twitter_accounts.first.client
following the documentation given here
The client object works fine. But I couldn't get DirectMessages in the same way.
Also followed this documentation. Here I could not find a way to get DirectMessages. Is there a way in REST API to get twitter direct messages. Or do I need to implement Streaming API.
http://www.rubydoc.info/gems/twitter/Twitter/REST/Client
Methods included from DirectMessages
#create_direct_message, #destroy_direct_message, #direct_message, #direct_messages, #direct_messages_received, #direct_messages_sent
These map to the REST API endpoints
https://dev.twitter.com/rest/reference/get/direct_messages
https://dev.twitter.com/rest/reference/get/direct_messages/sent
n.b. you won't get group messages through this API and will need to rebuild an inbox model e.g. sequence replies of replies between yourself and the recipient.

How to programmatically check if a live YouTube channel is streaming?

My company runs a live web stream and has started duplicating this to YouTube. Unfortunately the staff won't check if it's live and internet issues cause our web encoder to stop encoding at times.
Is there a programmatic way I can tell if a channel is ACTUALLY streaming? i.e. if live video is coming out the channel and not just that "the channel is live"?
You may use Search: list.
Using this request returns a collection of search results that match the query parameters that you have specified in the API request. Add part=snippet in your request since this is a required parameter. Then, you may add the following optional parameters with their corresponding values in your HTTP request:
channelId=[channelId] - to search resources created by a particular channel.
type=video - to retrieve a particular type of resource
eventType=live - to return only active broadcasts. Please note that if you use eventType, also set the type parameter's value to video.
Combining all of these parameters, you may send HTTP request using the following format:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCXswCcAMb5bvEUIDEzXFGYg&type=video&eventType=live
To better filter your search, you may also opt to add more parameters that are listed in supported parameters.
Lastly, solution in this related SO post - How to check if YouTube channel is streaming live might also help.

Meteor.JS YouTube Auth and Data

So what I've got now is hosted at http://exonia.meteor.com/ -- I've got Google authentication all working, and I've got the two YouTube scopes I want added and working as well. However, when I try to access any of the data from the YouTube API in the Users Collection, the only thing I have is the full name of the user, from their YouTube Profile.
How can I access the YouTube data?
EDIT: I've now deployed to the domain mentioned above, my apologies--was deploying to a custom domain and forgot about that one.
If everything is going as intended, you should have access to the Youtube information in the server. If that's the case, then you need to tell Meteor to also expose that information to the client by publishing it (only basic info is published by default).
For instance, if you want to add some extra fields to the user object from the data you've received from Youtube, do something like this:
Meteor.publish("extra_fields", function() {
return Meteor.users.find(
{_id: this.userId},
{fields: {fieldYouWantToPublish: 1}} // 1 indicates you want to include that field
);
});
Meteor will automatically merge the requested fields into the user object for you. Don't forget to subscribe to it!

Resources