Twitch API Get Followers

I’m trying to attract the last people watching that channel with a specific user ID, but users seem to be object console log Screenshot: https://imgur.com/a/sm4E6Qq
Code Link: http://dpaste.com/1CCKYRB

Why are you using a chatbot to load the followers endpoint?

There is no endpoint to get “the last people watching a channel”

client.api({
    url: "https://api.twitch.tv/kraken/channels/115307371/follows",
    headers: {
        "Accept": "application/vnd.twitchtv.v5+json",
        "Authorization": "oauth:key",
        "Client-ID": "client-id"
    }
}, function(err, res, body) {
    console.log(body);
});

should be

client.api({
    url: "https://api.twitch.tv/kraken/channels/115307371/follows",
    headers: {
        "Accept": "application/vnd.twitchtv.v5+json",
        "Authorization": "OAuth key",
        "Client-ID": "client-id"
    }
}, function(err, res, body) {
    console.log(body);
});

For kraken

But you first screenshot shows the helix data model

I’m really not sure what you are trying to do here

In fact, this file only stands inside chatbot files, it doesn’t work with it. When I want to see the last followers, I run the file by saying the node file name in the visual studio console and looking at the responses on the console. But now usernames only appear as objects

Then iterate the object

Console.log will do blind dump out everything, it only goes to a certain depth, by default

using nodejs, for example

const got = require('got');

got({
    url: 'https://api.twitch.tv/kraken/channels/115307371/follows',
    headers: {
        "Client-ID": "yourclient",
        "Accept": "application/vnd.twitchtv.v5+json",
    },
    responseType: 'json'
})
.then(resp => {
    for (var x=0;x<resp.body.follows.length;x++) {
        console.log(resp.body.follows[x]);
    }
})
.catch(err => {
    console.log(err);
})

You are using bot code for no sane reason.

Thank you. After downloading the module, the results improved. I was able to see username, profile photos and other information on the console

I have one more question. How can I just get display_name in response? I don’t want identity, species and others to appear. I just want display_name to appear
Code: <?php
$headers = array(
‘Accept: application/vnd.twitchtv.v5+json’,
‘Authorization: OAuth key’,
);

$url = ‘https://api.twitch.tv/kraken/users/user-id’;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);

$result = curl_exec($ch);
curl_close($ch);

echo $result;
?>

Response: https://imgur.com/BjMNqCP

const got = require('got');

got({
    url: 'https://api.twitch.tv/kraken/channels/115307371/follows',
    headers: {
        "Client-ID": "yourclient",
        "Accept": "application/vnd.twitchtv.v5+json",
    },
    responseType: 'json'
})
.then(resp => {
    for (var x=0;x<resp.body.follows.length;x++) {
        console.log(resp.body.follows[x].user.display_name);
    }
})
.catch(err => {
    console.log(err);
})

Thank you for help

Oh you switched from the followers endpoint to the users endpoint and changed languages.

Thats what happens when you delete the reply whilst I was reading it…

$result = curl_exec($ch);
curl_close($ch);

$result = json_decode($result);
echo $result->display_name;

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