Show last follow (php)

Hello,

for several months the display has no longer worked.
before, I use
https://api.twitch.tv/helix/users/follows?first=1&to_id=’.TWITCH_ID but now show error.
now I want test with
https://api.twitch.tv/helix/channels/followers?broadcaster_id=’.TWITCH_ID;

$ch = curl_init("https://id.twitch.tv/oauth2/token?client_id=".CLIENT_ID."&client_secret=".CLIENT_SECRET."&grant_type=client_credentials");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json'
  ));
  $response = curl_exec($ch);
  $data = json_decode($response, true);


$ch = curl_init('https://api.twitch.tv/helix/channels/followers?broadcaster_id='.TWITCH_ID);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Client-ID: ' . CLIENT_ID,
    'Authorization: Bearer ' . $data['access_token']
  ));

$r = curl_exec($ch);
$i = curl_getinfo($ch);

The code return this, my array is empty
{“total”:494,“data”:,“pagination”:{}}

Thanks for your help

You have the wrong token type

The new follows API requires authentication from the broadcaster with the relevant scope attached

See Reference | Twitch Developers for scope requirements

For your use case you would normally use a code flow token Getting OAuth Access Tokens | Twitch Developers

Alternately after getting broadcaster permission you can use EventSub and Twitch will tell you the new follow(s) - EventSub Subscription Types | Twitch Developers

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