adamhebby/glimeshclient

PHP Client for GraphQL API on https://glimesh.tv/api

v1.1.0 2022-05-08 19:54 UTC

This package is auto-updated.

Last update: 2022-11-23 03:23:13 UTC


README

This Library aims to provide a fully working Glimesh Client, all objects and interfaces used by the API are auto-generated by the API specification.

Installation

composer require adamhebby/glimeshclient

Usage

<?php

use GlimeshClient\Adapters\Authentication\OAuthFileAdapter;
use GlimeshClient\Client;
use GlimeshClient\Objects\Enums\ChannelStatus;
use GraphQL\Query;
use GuzzleHttp\Client as GuzzleHttpClient;
use Symfony\Component\Dotenv\Dotenv;

require_once __DIR__ . '/../vendor/autoload.php';

// Dotenv is not required!
$dotenv = (new Dotenv())->load(__DIR__ . '/../.env');

$logger = new \Monolog\Logger("log");
$logger->pushHandler(new \Monolog\Handler\ErrorLogHandler());

$guzzle = new GuzzleHttpClient(['http_errors' => true, 'allow_redirects' => true]);

$client = new Client(
    $guzzle,
    new OAuthFileAdapter(
        $_ENV['CLIENT_ID'],
        $_ENV['CLIENT_SECRET'],
        '/tmp/auth.json'
    ),
    $logger
);

$object = $client->makeRequest(
    (new Query('channels'))->setSelectionSet([
        'id',
        (new Query('stream'))->setSelectionSet([
            'thumbnail',
        ]),
    ])->setArguments(['status' => 'ENUM:' . ChannelStatus::LIVE])
);

var_dump($object);