1111
1
Hello, can someone help please
How can I get count of user followers
I try this code but 404
Thanks!
<?php
header('Content-Type: application/json');
$videosApi = 'https://api.twitch.tv/kraken/users/<user_name>/followers';
$clientId = '';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
"Accept: application/vnd.twitchtv.v5+json",
'Client-ID: ' . $clientId
),
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $videosApi
));
$response = curl_exec($ch);
curl_close($ch);
//decode the response
$json = json_decode($response, JSON_PRETTY_PRINT);
//print response
print_r($json);
Legacy V5 Kraken uses the userID not the username in the Get Followers API
Additionally thats the wrong URL anywah
You want Reference | Twitch Developers
or to upgrade to the latest API see
1111
3
Thank you
Also one question please
Can I some how use username (not user_id)
(It’s not very comfortable for my task)
Or get this user_id from api and input into GET followers
Use the get Users API to convert a name to an ID
1111
5
Thank you
So now I Try to get (name to id) but “Invalid OAuth token”
with that code : (I try to put in oauth secret, also i try to get it by this doc https://dev.twitch.tv/docs/authentication/getting-tokens-oauth):
<?php
header('Content-Type: application/json');
$videosApi = 'https://api.twitch.tv/helix/users?login=pokanoname&login=pokanoname';
$clientId = client'id';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
"Accept: application/vnd.twitchtv.v5+json",
'Client-ID: ' . $clientId,
"Authorization: OAuth oauth_code"
),
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $videosApi
));
$response = curl_exec($ch);
curl_close($ch);
$json = json_decode($response, JSON_PRETTY_PRINT);
print_r($json);
For Helix you don’t need the accept header and the auth token needs the prefix of Bearer
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId,
"Authorization: Bearer oauth_code"
),
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $videosApi
));
Make sure you are generating a token and not using the client secret you can find an example of that here https://github.com/BarryCarlyon/twitch_misc/tree/main/authentication/app_access_tokens/php
1111
7
I put my Secret and ID but
“Invalid message” (Its on localhost)
That is a PHP error saying that config.php doesn’t exist at the location specified
system
Closed
10
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.