I’m working on a website for a Twitch streamer that has a sub button.
On his website I have a “Connect with Twitch” button that uses the &scope=user_read+user_subscriptions tag.
All that works fine.
Now my question is: How can I send subscribed accounts to one page, and non-subscribed accounts to a different one? Also, how do I make this page only reachable if user_subscriptions = true?
Use the /users/:user/subscriptions/:channel endpoint with the channel name and the access token. You can see example data and status codes on the page I linked. Use the status codes to check if a user is subscribed/not subscribed.
I need help on how to do this. How and where do I exec status codes? And how can I link this to give access to a page, and if return=false then no access.
The API returns a JSON object. You will most likely have to convert the JSON object into an object the language understands (such as PHP’s json_decode()) before you can access those values. If the “status” value of the object is set, don’t give access and maybe display the “error” value. You can use any of the other values to verify if the user is subscribed (such as “_id” or “created_at”).