I’m autistic and pretty stupid, so misunderstanding things is my natural habitat. Thank you for your patience in trying to explain it to me!
That said I think I see what you’re getting at now. There is a callback script for the website login where the Oauth scopes are listed including ‘channel:read:subscriptions’ associated with the broadcaster ID in question - whenever I’ve updated it in the past to add new things, he gets a pop-up on logging back in to confirm authorization for the new thing. I’m entirely unsure of most of the terminology which adds to the confusion.
This is what I have so far:
$callbackURL = 'http://www.shamblingincompetence.com/auth/EVENTSUB-subscriptions.php';
$BCID = '501071947';
$secret = 'REMOVED';
$clienttoken = 'REMOVED' // *
$CSRdata = array(
'type' => 'channel.subscription',
'version' => '1',
'condition' => '{"broadcaster_user_id":'.$BCID.'}',
'transport' => '{"method":"webhook","callback".'.$callbackURL.',"secret":"'.$secret.'"}'
);
$CSdatainput = json_encode($CSRdata);
$CScurl = curl_init('https://api.twitch.tv/helix/eventsub/subscriptions');
curl_setopt($CScurl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($CScurl, CURLOPT_POSTFIELDS, $CSdatainput);
curl_setopt($CScurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($CScurl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$clienttoken,
'Client-ID: '.$clientid,
'Content-Type: application/json',
));
echo "<pre><h3>";
var_dump($CSoutput);
echo "</h3></pre>";
$CSoutput = curl_exec($CScurl);
$CSinfo = curl_getinfo($CScurl);
curl_close($CScurl);
if ($CSinfo['http_code'] == 200) {
$CSjson = json_decode($CSoutput);
if (json_last_error() == JSON_ERROR_NONE) {
echo 'Got JSON';
print_r($CSjson);
} else {
echo 'Got a JSON decode error with ' . $CSoutput;
}
} else {
echo 'Got a ' . $CSinfo['http_code'] . ' with ' . $CSoutput;
}
- assuming I’ve made no other mistakes (highly improbable) I’m assuming the $clienttoken is the point of failure (given the response is Got a 401 with {“error”:“Unauthorized”,“status”:401,“message”:“Must provide valid app token.”}. I’m concerned that if I get a new one it’ll break the entire website because I’m not sure what else uses it and I can’t ask the person who set it up. It sounds like I’d have an easier time doing follows rather than subscriptions, but that does mean I’d just be back with the same problem later. As always, help is so very appreciated