API Update cronjob script

Hello @all, i have a big problem and i need your help thats will be really nice.

I develop years ago a plugin for woltlab cms to show twitch partners, but now sice 1 month the plugin is not more working about the api change, i have no idea what is the problem and i hope someone can help me out to bring me at the right point.

this is the cronjob witch runs and store the datas in a sql table but the cronjob is not more puttin datas to sql about worng api

i hope someone can help me, thanks a lot

https://pastebin.com/eunSh9LH

Line 129 calls an API that doesn’t exit

$request = new HTTPRequest(self::API_BASE . ‘/streams/?channel=’ . implode(’,’, $channels) . ‘&client_id=’ . STREAMING_PARTNER_TWITCH_CLIENT_ID);

And is just flat calling Helix wrong, this should work:

$request = new HTTPRequest(self::API_BASE . ‘/streams/?login=’ . implode(’&login=’, $channels));

Line 90 calls an API end point that doesn’t exist on Helix.

$request = new HTTPRequest(self::API_BASE . ‘/channels/’ . $channelData[‘data’][‘name’] . ‘?client_id=’ . STREAMING_PARTNER_TWITCH_CLIENT_ID);

Should be something like

$request = new HTTPRequest(self::API_BASE . ‘/users/?id’ . $channelData[‘data’][‘id’]);

And your ClientID needs to be moved to a Header for All Requests

It looks like this script was migrated from API v3, skipping v5, straight to helix and wasn’t correctly modified for helix

Thanks BarryCarlyon for all your help about the header i read the api already maybe you can give me a example how i can add the header into my script ? thats will be really nice thanks for all

I am unfamiliar with the wcf\util\HTTPRequest library

So I’d have to go look up the documentation for you, which I cannot do at this time

thank you so far i can fully understand :smiley:

maybe someone other has a idea how i can put the header into the cronjob

You need to go look up the documentation for wcf\util\HTTPRequest which tell you how to add headers.

This is the Twitch API support forum, not the “wcf\util\HTTPRequest PHP support forum”

I can tell you how to add headers to as basic PHP cURL request, but using a library, you need to lookup the documentation for that library.

https://lmgtfy.com/?q=php+wcf+util+http+request+add+header&s=g

An example:

https://hotexamples.com/examples/wcf.util/HTTPRequest/addHeader/php-httprequest-addheader-method-examples.html

also provides an example

Here is the full manual

http://docs.php.net/manual/tw/class.httprequest.php

Which suggests using this function

http://docs.php.net/manual/tw/httprequest.addheaders.php

Thanks i read now all and add the headers but now i get Received status code ‘401’ from server

https://pastebin.com/43X9U2J5

I typoed

$request = new HTTPRequest(self::API_BASE . ‘/users/?id’ . $channelData[‘data’][‘id’]);

Should be

$request = new HTTPRequest(self::API_BASE . ‘/users/?id=’ . $channelData[‘data’][‘id’]);

Please refer to the documentation:

hmm but still 401 =(

401 with what error message?

here the full log

https://pastebin.com/jBWzkc3C

And whats the body response from the server?

What was the call that was actually made by the script to the Twitch API.

Neither of these things are in the output you have provided.

Failed to load resource: the server responded with a status of 503 (Service Unavailable)

this script is a cronjob and i run it from here https://prnt.sc/pv1rv2 its just the same script what i run

503 is basically “try again later we screwed up”

You screenshot tells me nothing other than you are using some weird UI I’ve never seen to test and schedule cronjobs.

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