Oufti
September 16, 2019, 4:21pm
1
Hi everyone,
I have a simple script that works since 2017 in PHP : show the streams of a particular game and language (french).
Since a few days this one does not work anymore.
The request was the following (it worked well) :
https://api.twitch.tv/kraken/streams/?game=MYGAME&language=fr&client_id=XXXX
I replaced kraken with helix.
But I have a 401 error that appears: “Must provide a valid Client-ID or OAuth token”.
I did not change anything in my twitch developers panel. My cliend id is still valid.
What is the problem ?
Thanks for you help.
You must change the following
Send game_id
instead of game
Get the game ID for your game here:
Send the client ID as a header not as a query string
In PHP this is via setting a Header as a curl option
https://www.php.net/curl_setopt
CURLOPT_HTTPHEADER
An array of HTTP header fields to set, in the format array('Content-type: text/plain', 'Content-length: 100')
So, (incomplete code snippet):
$ch = curl_init('https://api.twitch.tv/helix/streams?game_id=123');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Client-ID: YourClientID'));
For example
system
Closed
October 16, 2019, 4:36pm
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.