Skip to content

how do i actually fetch the data? #13

Answered by Sainan
nonchip asked this question in Q&A
Discussion options

You must be logged in to vote

The "selected answer" unfortunately broke as Twitch dropped API v5.

Instead, the token can now be obtained via the GraphQL API like so:

$ch = curl_init("https://gql.twitch.tv/gql");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
        "Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko"
    ],
    CURLOPT_POSTFIELDS => '[{"operationName":"ExtensionsForChannel","variables":{"channelID":"123858856"},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d52085e5b03d1fc3534aa49de8f5128b2ee0f4e700f79bf3875dcb1c90947ac3"}}}]',
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
// var_dump($data);

foreach ($data[0]['data'

Replies: 4 comments 14 replies

Comment options

You must be logged in to vote
1 reply
@TobiTenno
Comment options

Comment options

You must be logged in to vote
11 replies
@TobiTenno
Comment options

@TobiTenno
Comment options

@TobiTenno
Comment options

@derrod
Comment options

@TobiTenno
Comment options

Comment options

You must be logged in to vote
0 replies

This comment was marked as disruptive content.

@TobiTenno
Comment options

@TobiTenno
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #5 on July 12, 2021 19:49.