Twitch stream on my website constantly gone

$account_is_logged_in =  (bool) db_query_range
  'SELECT 1 FROM {sessions} WHERE uid = :uid AND timestamp > :timestamp',
    ':uid' => $row->uid,
    ':timestamp' => REQUEST_TIME - (60 * 1),

$channelsApi = '*****&user_login=';

$result = db_select('field_data_field_twitch_username', 'r')
 $clientId = '*****';
 $ch = curl_init();
 curl_setopt_array($ch, array(
       'Client-ID: ' . $clientId,
       'Authorization: Bearer *****',
    CURLOPT_URL => $channelsApi.$channelName

 $response = curl_exec($ch);

return $offline;


Im using this code to display my livestream and people of my clan on my website, but somehow twitch changes smth and i have to recode the code every week or smth…

this code checks whos online on twitch… if he has the twitchstreaemer role on the website and when he does the stream comes automaticly on my homepage.

but somehow twitch changes stuff and i have to figure out what changed and recode the thing wich cost me ages of time to fix (not a pro in coding).

can one of u tell me what i can change so i dont have to recode all the time?.

im using drupal btw.


Nothing has changed recently.

Your code doesn’t seem to use an oAuth token, and you seem to be using client_id as a query string param, helix only accepts ClientID and token via header

This change came in quite a while ago, not last week

You’ll probably use an App Access token:

You may also be interested in EventSub as eventSub will tell you where a channel goes live/offline and saves a lookup

thanks for the quick reply, but doesnt this

       'Client-ID: ' . $clientId,
       'Authorization: Bearer *****',

say that its in the header?

I saw this which is in error

I didn’t see this section as it was out of view and I didn’t scroll your code. My bad.

This is correct.

So there does not seem anything obviously wrong in your code.

Other than no HTTP code checking or checking if the response was an error or not.

If your token is hard coded it may have expired

Aaahh awesome i got it now, i changed the bearer token via
and the stream is working again, now i have to find out how to generate an token automaticly :), many thanks for the help man, it really helped me out figuring out what was going wrong!, THANKS!

Yeah don’t use other peoples generators

I already linked you the docs

You can and should use an app access token:

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