Problems converting to the new API with subscribers

I have a webpage that returned the most recent 3 subscribers, howevr ever since API V5 was depreciated it no longer works. And i cannot for the life of me figure out how to switch to the Helix API.

My old code was like this,
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.twitch.tv/kraken/channels/champdrivescars/subscriptions?limit=3&direction=desc”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “GET”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Client-ID: ####’,
‘Authorization: OAuth ####’
));

Client ID came from my developer app although I do remember where the OAuth key came from.

But I tried to switch it to this…
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.twitch.tv/helix/subscriptions?broadcaster=424051192”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “GET”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Client-ID: ####’,
‘Authorization: Bearer ####’
));

First off, I have no idea if that is my broadcaster id or not, cant seem to find any info on where you get that, also I am using the same client id from my app, and I see that oauth should be switched to Bearer, but again no idea where that key comes from, and i get the error Missing channel:read:subscriptions scope

Any help is appreciated, not super familiar with this but I am using PHP to try and get the data.

First off, v5 is deprecated but it still works perfectly fine, and will continue to work as there is currently no planned removal date. It was v3 that was removed and because your request there is using v3 it’s not working.

Secondly, your broadcaster id is your user ID, you can use the Get Users endpoint to see what your user id is: https://dev.twitch.tv/docs/api/reference#get-users

Finally, to get an OAuth token with the correct scope you’ll need to go through the Authentication process, specify the scope you wish to ask permission for, and then go through that auth flow to be granted a token that you can use. Details for the auth process can be found here: https://dev.twitch.tv/docs/authentication/getting-tokens-oauth

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.