1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-10 02:26:37 +02:00

fix: small notice errors (#3677)

* fix notice

* fix notice

* tweak

* tweaks
This commit is contained in:
Dag
2023-09-20 03:15:15 +02:00
committed by GitHub
parent e6aef73a02
commit 0bf38e5c56
4 changed files with 29 additions and 27 deletions

View File

@@ -90,7 +90,8 @@ EOD;
'channel' => $channel,
'types' => self::BROADCAST_TYPES[$type]
];
$data = $this->apiRequest($query, $variables);
$response = $this->apiRequest($query, $variables);
$data = $response->data;
if ($data->user === null) {
throw new \Exception(sprintf('Unable to find channel `%s`', $channel));
}
@@ -205,37 +206,29 @@ EOD;
);
}
// GraphQL: https://graphql.org/
// Tool for developing/testing queries: https://github.com/skevy/graphiql-app
/**
* GraphQL: https://graphql.org/
* Tool for developing/testing queries: https://github.com/skevy/graphiql-app
*
* Official instructions for obtaining your own client ID can be found here:
* https://dev.twitch.tv/docs/v5/#getting-a-client-id
*/
private function apiRequest($query, $variables)
{
$request = [
'query' => $query,
'variables' => $variables
'query' => $query,
'variables' => $variables,
];
/**
* Official instructions for obtaining your own client ID can be found here:
* https://dev.twitch.tv/docs/v5/#getting-a-client-id
*/
$header = [
'Client-ID: kimne78kx3ncx6brgo4mv6wki5h1ko'
$headers = [
'Client-ID: kimne78kx3ncx6brgo4mv6wki5h1ko',
];
$opts = [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($request)
CURLOPT_POSTFIELDS => json_encode($request),
];
Logger::debug("Sending GraphQL query:\n" . $query);
Logger::debug("Sending GraphQL variables:\n" . json_encode($variables, JSON_PRETTY_PRINT));
$response = json_decode(getContents('https://gql.twitch.tv/gql', $header, $opts));
Logger::debug("Got GraphQL response:\n" . json_encode($response, JSON_PRETTY_PRINT));
if (isset($response->errors)) {
$messages = array_column($response->errors, 'message');
throw new \Exception(sprintf('twitch api: `%s`', implode("\n", $messages)));
}
return $response->data;
$json = getContents('https://gql.twitch.tv/gql', $headers, $opts);
$result = Json::decode($json, false);
return $result;
}
public function getName()