Salja
November 10, 2019, 3:17pm
1
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
Salja
November 10, 2019, 3:30pm
3
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
Salja
November 10, 2019, 3:41pm
5
thank you so far i can fully understand
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
<?php
namespace wcf\util;
use wcf\system\exception\HTTPNotFoundException;
use wcf\system\exception\HTTPServerErrorException;
use wcf\system\exception\HTTPUnauthorizedException;
use wcf\system\exception\SystemException;
use wcf\system\io\RemoteFile;
use wcf\system\Regex;
use wcf\system\WCF;
use wcf\util\exception\HTTPException;
/**
* Sends HTTP/1.1 requests.
* It supports POST, SSL, Basic Auth etc.
*
* @author Tim Duesterhus
* @copyright 2001-2018 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\Util
*/
This file has been truncated. show original
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
Salja
November 10, 2019, 6:22pm
7
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:
401 with what error message?
Salja
November 10, 2019, 6:35pm
11
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.
Salja
November 10, 2019, 6:41pm
13
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.
system
Closed
December 10, 2019, 6:43pm
15
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.