Can I get my subscriber list with a GET request only?

I have a client ID and oauth token already, but it doesn’t seem to work

What endpoint are you requesting? What scopes are on your token?

I was trying this$username/subscriptions/?client_id=$client_id&secret_token=$oauth_token

also tried token instead of secret_token

I get 401 unauthorised in incognito mode, but it works (with ?client_id only) if I’m logged in to twitch

the token has no scopes

When you’re logged in to Twitch it’ll likely be using permissions from your currently logged in account. If you logout of Twitch you should get the same response as incognito.

Secondly, secret_token isn’t the correct way to send OAuth tokens. You should be setting the Authorization header as specified in the docs

Finally, if your token has no scopes then it can’t access that endpoint anyway, the deprecated v5 endpoint requires channel_subscriptions , or if you want to use the up to date Helix endpoint you need the channel:read:subscriptions scope.

OK ty.

What I was looking for is something I could just simply request with PHP’s file_get_contents() but I just found out you can send headers with that.

This is the only thing I need to use the API for, so I guess I might as well go with Helix?

Edit: all sorted and working :slight_smile: ty dist

Don’t use file_get_contents

On most hosting providers worth their salt, file_get_contents will not work for security reasons.

Please use cURL (this goes for any sort of requests you may make in PHP)

Here is a cURL example (Add this function and append _curl to all your file_get_contents.)

/* file_get_contents replaced with curl function - Add this function and replace any use of file_get_contents with file_get_contents_curl */

function file_get_contents_curl($url) {
    $curlHeader = array(
        "Accept: application/vnd.twitchtv.v5+json",
        "Authorization: OAuth xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    $ch         = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeader);
    $data = curl_exec($ch);
    return $data;

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