How do I capture youtube live chat messages in construct 3?

1 favourites
  • 13 posts
From the Asset Store
Chat with smart animals using the OpenAi Chat GPT 3 API
  • I want to integrate youtube live chat into my game. I saw an article online that mentioned that Ajax could be used, but there wasn't much information in the article.

    https://www.construct.net/en/forum/construct-3/how-do-i-8/youtube-api-145889

    I wonder if there is a way to capture youtube live chat messages in construct 3?

  • developers.google.com/youtube/v3/live/docs/liveChatMessages

    developers.google.com/youtube/v3/live/docs/liveChatMessages/list

    Via HTTP, use the AJAX plugin to GET, through the 'Request URL' action.

    GET https://youtube.googleapis.com/youtube/v3/liveChat/messages?key=[YOUR_API_KEY] HTTP/1.1
    

    Use the AJAX plugin to set headers, through the 'Set request header' action.

    Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
    

    The response will be in JSON, which you can load into the json object to parse and use, or you could possibly just grab what you need directly with tokenat.

    Alternatively, you can use the javascript API directly with C3. Documentation and examples also at the above links.

  • developers.google.com/youtube/v3/live/docs/liveChatMessages

    https://developers.google.com/youtube/v3/live/docs/liveChatMessages/list#try-it

    Via HTTP, use the AJAX plugin to GET, through the 'Request URL' action.

    > GET https://youtube.googleapis.com/youtube/v3/liveChat/messages?key=[YOUR_API_KEY] HTTP/1.1
    

    Use the AJAX plugin to set headers, through the 'Set request header' action.

    > Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
    

    The response will be in JSON, which you can load into the json object to parse and use, or you could possibly just grab what you need directly with tokenat.

    Alternatively, you can use the javascript API directly with C3. Documentation and examples also at the above links.

    I don't know where to get ACCESS_TOKEN and how can I specify the exact youtube live stream?

    Still, thanks for the response, you gave me a way

  • You do that on the YouTube side, when setting up your stream.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You do that on the YouTube side, when setting up your stream.

    I connect as you said, but it returns this 401 error

    What do I need to do?

  • developers.google.com/youtube/v3/live/docs/liveChatMessages

    https://developers.google.com/youtube/v3/live/docs/liveChatMessages/list#try-it

    Via HTTP, use the AJAX plugin to GET, through the 'Request URL' action.

    > GET https://youtube.googleapis.com/youtube/v3/liveChat/messages?key=[YOUR_API_KEY] HTTP/1.1
    

    Use the AJAX plugin to set headers, through the 'Set request header' action.

    > Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
    

    The response will be in JSON, which you can load into the json object to parse and use, or you could possibly just grab what you need directly with tokenat.

    Alternatively, you can use the javascript API directly with C3. Documentation and examples also at the above links.

    What data besides API_KEY is required to crawl youtube Livechat messages?

    I checked it for a long time on the Internet, I couldn't find the right solution. Please save me.

  • https://www.youtube.com/watch?v=JkKxDAic3IE&ab_channel=sDoddler

    I watched this video, found the LiveChatID and put it in the program

    But he still made an error

    But the URL of the request already contains the information of my live broadcast, how can I bring the information into the game?

  • You need to add the part parameter "snippet" to get the snippet data. Use the second link to see how it should look when adding parameters in get request. Similar to how you added the livechat Id parameter.

  • You need to add the part parameter "snippet" to get the snippet data. Use the second link to see how it should look when adding parameters in get request. Similar to how you added the livechat Id parameter.

    I have found a way

    Now he looks like this

    But it still doesn't make it into the game

    Always getting "failed: 401" error

    How can I get the data to pass correctly into the game?

  • A 401 error code means that you don't have authorization to that resource. It is possible that the request is working in the browser because you are logged in to Youtube with your account.

    I think that you need to generate some OAuth 2.0 authorization credentials to use that API.

    developers.google.com/youtube/v3/live/registering_an_application

    Can't really help you more, but I would look into that.

  • A 401 error code means that you don't have authorization to that resource. It is possible that the request is working in the browser because you are logged in to Youtube with your account.

    I think that you need to generate some OAuth 2.0 authorization credentials to use that API.

    https://developers.google.com/youtube/v3/live/registering_an_application

    Can't really help you more, but I would look into that.

    I've tried putting it on my website and it's still the same

    I'll give it a try with OAuth 2.0, thanks

  • A 401 error code means that you don't have authorization to that resource. It is possible that the request is working in the browser because you are logged in to Youtube with your account.

    I think that you need to generate some OAuth 2.0 authorization credentials to use that API.

    https://developers.google.com/youtube/v3/live/registering_an_application

    Can't really help you more, but I would look into that.

    Now that I have OAuth 2.0 authorization credentials, how do I put authentication into my game?

  • developers.google.com/identity/protocols/oauth2

    developers.google.com/identity/protocols/oauth2/javascript-implicit-flow

    Sorry for just referring you to documentation, but this is pretty out of the scope of these forums (and my experience). That said, if you learn how to read and follow documentation, you'll be able to do pretty much anything.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)