I’m really trying my best to understand how to achieve this.
I want to embed streams into my Wordpress site. Using javascript, I want to say if user online display video, if else display other user etc.
How do I do this? I’ve been reading the API and I don’t get it! I really need help, please.
Using Pure JS under Wordpress doesn’t work well.
To call the API requires a token.
And to get a token you are either a server, or you are logging the user in.
You don’t want to have to login a user just to get a Live Stream status.
So heres what I would do
- Use EventSub to collect Stream Up/Down into wordpress options/config table.
- Feed that to the frontend to display as needed
Or
- Generate a Client Credentails token https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow
- Store that in wp options
Then either
-
Long Poll the streams API and cache that data into options using WPCtron
-
Use a WP action callback to call the API using the token at page load time to lookup the streams you are interested in. And cache that too
-
Front end calls your Wordpress backend vai an API/Cron Style
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.