Giter VIP home page Giter VIP logo

twitch-api-php's Introduction

Twitch API PHP Library

Packagist Version Packagist PHP Version Support Packagist Downloads Packagist License

The Twitch API PHP Library allows you to interact through HTTP to a number of Twitch API endpoints. The library does not format the repsonses of your request so you have full flexability in how to handle the data that is returned from the API.

Documentation & Links

Getting Started

Requirements

  • PHP 7.4 - The library has been shown to work on earlier versions but we encourage you to use the latest versions of PHP that are tested with our library. - The requirement will be increased to PHP 8.0 in the future, so you should develop for the latest version of PHP.
  • Composer
  • ext-json: *
  • guzzlehttp/guzzle ~6.0|~7.0

Installation

The recommended way to install the Twitch API PHP Library is through Composer.

composer require nicklaw5/twitch-api-php

Example Usage

All calls to the Twitch API require bearer tokens that can be retrieved through the OauthApi class. You can review the types of tokens in the Twitch API docs. The below examples store the Client ID, Secret and Scopes directly in the example, but you should not do this. Store your IDs, Secret, and Scopes in a secure place such as your database or environment variables or alternate settings storage. Security of this information is important. Here is an example of how you can retrieve a token for your application:

$twitch_client_id = 'TWITCH_CLIENT_ID';
$twitch_client_secret = 'TWITCH_CLIENT_SECRET';
$twitch_scopes = '';

$helixGuzzleClient = new \TwitchApi\HelixGuzzleClient($twitch_client_id);
$twitchApi = new \TwitchApi\TwitchApi($helixGuzzleClient, $twitch_client_id, $twitch_client_secret);
$oauth = $twitchApi->getOauthApi();

try {
    $token = $oauth->getAppAccessToken($twitch_scopes ?? '');
    $data = json_decode($token->getBody()->getContents());

    // Your bearer token
    $twitch_access_token = $data->access_token ?? null;
} catch (Exception $e) {
    //TODO: Handle Error
}

Here is an example of how you retrieve a users token:

$twitch_client_id = 'TWITCH_CLIENT_ID';
$twitch_client_secret = 'TWITCH_CLIENT_SECRET';
$twitch_scopes = '';

$helixGuzzleClient = new \TwitchApi\HelixGuzzleClient($twitch_client_id);
$twitchApi = new \TwitchApi\TwitchApi($helixGuzzleClient, $twitch_client_id, $twitch_client_secret);
$oauth = $twitchApi->getOauthApi();

// Get the code from URI
$code = $_GET['code'];

// Get the current URL, we'll use this to redirect them back to exactly where they came from
$currentUri = explode('?', 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])[0];

if ($code == '') {
    // Generate the Oauth Uri
    $oauthUri = $oauth->getAuthUrl($currentUri, 'code', $twitch_scopes);
    // Redirect them as there was no auth code
    header("Location: {$oauthUri}");
} else {
    try {
        $token = $oauth->getUserAccessToken($code, $currentUri);
        // It is a good practice to check the status code when they've responded, this really is optional though
        if ($token->getStatusCode() == 200) {
            // Below is the returned token data
            $data = json_decode($token->getBody()->getContents());

            // Your bearer token
            $twitch_access_token = $data->access_token ?? null;
        } else {
            //TODO: Handle Error
        }
    } catch (Exception $e) {
        //TODO: Handle Error
    }
}

When you have a user token that is expired, you're able to refresh it instead of requiring them to authenticate again. Here is an example of how you refresh a users token:

$twitch_client_id = 'TWITCH_CLIENT_ID';
$twitch_client_secret = 'TWITCH_CLIENT_SECRET';
$twitch_scopes = '';
$user_refresh_token = 'REFRESH_TOKEN';

$helixGuzzleClient = new \TwitchApi\HelixGuzzleClient($twitch_client_id);
$twitchApi = new \TwitchApi\TwitchApi($helixGuzzleClient, $twitch_client_id, $twitch_client_secret);
$oauth = $twitchApi->getOauthApi();

try {
    $token = $oauth->getAppAccessToken($twitch_scopes ?? '');
    $data = json_decode($token->getBody()->getContents());

    // Your bearer token
    $twitch_access_token = $data->access_token ?? null;

    // The scopes from the API
    $twitch_scopes = $data->scope;
} catch (Exception $e) {
    //TODO: Handle Error
}

Usage of the API Classes

Everything stems from the TwitchApi class. However, if you want to individually instantiate UsersApi, OauthApi, etc. you are free to do so.

The API calls generally return an object implementing ResponseInterface. Since you are getting the full Response object, you'll need to handle its contents, e.g. by decoding then into an object with json_decode(). This library does not assume this is what you want to do, so it does not do this for you automatically. This library simply acts as a middleman between your code and Twitch, providing you with the raw responses the Twitch API returns.

The individual API classes that can be called from TwitchApi correspond to the Twitch API documentation. The rest of the API classes are based on the resources listed here. The methods in the classes generally correspond to the endpoints for each resource. The naming convention was chosen to try and match the Twitch documentation. Each primary endpoint method (not convenience or helper methods) should have an @link annotation with a URL to that endpoint's specific documentation.

Here is a sample of retrieving a users table from their access token:

$twitch_client_id = 'TWITCH_CLIENT_ID';
$twitch_client_secret = 'TWITCH_CLIENT_SECRET';
// Assuming you already have the access token - see above
$twitch_access_token = 'the token';

// The Guzzle client used can be the included `HelixGuzzleClient` class, for convenience.
// You can also use a mock, fake, or other double for testing, of course.
$helixGuzzleClient = new \TwitchApi\HelixGuzzleClient($twitch_client_id);

// Instantiate TwitchApi. Can be done in a service layer and injected as well.
$twitchApi = new TwitchApi($helixGuzzleClient, $twitch_client_id, $twitch_client_secret);

try {
    // Make the API call. A ResponseInterface object is returned.
    $response = $twitchApi->getUsersApi()->getUserByAccessToken($twitch_access_token);

    // Get and decode the actual content sent by Twitch.
    $responseContent = json_decode($response->getBody()->getContents());

    // Return the first (or only) user.
    return $responseContent->data[0];
} catch (GuzzleException $e) {
    //TODO: Handle Error
}

Developer Tools

PHP Coding Standards Fixer

PHP Coding Standards Fixer (php-cs-fixer) has been added, specifically for the New Twitch API code. A configuration file for it can be found in .php_cs.dist. The ruleset is left at default (PSR-2 at this time). The configuration file mostly just limits it's scope to only the New Twitch API code.

You can run the fixer with vendor/bin/php-cs-fixer fix. However, the easiest way to run the fixer is with the provided git hook.

Git pre-commit Hook

In bin/git/hooks, you'll find a pre-commit hook that you can add to git that will automatically run the php-cs-fixer everytime you commit. The result is that, after the commit is made, any changes that fixer has made are left as unstaged changes. You can review them, then add and commit them.

To install the hook, go to .git/hooks and ln -s ../../bin/git/hooks/pre-commit.

License

Distributed under the MIT license.

twitch-api-php's People

Contributors

alexschastny avatar almostinteractive avatar b3none avatar brandin avatar brandonjbegle avatar dragony avatar echosa avatar johnrazeur avatar juan-tellez avatar julienmarliac avatar justas-s avatar lorenzosapora avatar maxhayman avatar nicklaw5 avatar nihaals avatar oldskool avatar radiojoe avatar rickynotaro avatar sofwar avatar thibaultvlacich avatar zlokomatic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitch-api-php's Issues

Add Numerous Endpoints with Body Params

checkAutomodStatus

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#check-automod-status
     */
    public function checkAutomodStatus(string $bearer, string $broadcasterId, string $msgId, string $msgText, string $userId): ResponseInterface
    {
        $queryParamsMap = $bodyParamsMap = [];

        $queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];

        $bodyParamsMap[] = ['key' => 'msg_id', 'value' => $msgId];

        $bodyParamsMap[] = ['key' => 'msg_text', 'value' => $msgText];

        $bodyParamsMap[] = ['key' => 'user_id', 'value' => $userId];

        return $this->postApi('moderation/enforcements/status', $bearer, $queryParamsMap, $bodyParamsMap);
    }

createStreamMarker

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#create-stream-marker
     */
    public function createStreamMarker(string $bearer, string $userId, string $description = null): ResponseInterface
    {
        $bodyParamsMap = [];

        $bodyParamsMap[] = ['key' => 'user_id', 'value' => $userId];

        if ($description) {
            $bodyParamsMap[] = ['key' => 'description', 'value' => $description];
        }

        return $this->postApi('streams/markers', $bearer, [], $bodyParamsMap);
    }

modifyChannelInfo

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#modify-channel-information
     */
    public function modifyChannelInfo(string $bearer, string $broadcasterId, string $gameId = null, string $language = null, string $title = null): ResponseInterface
    {
        $queryParamsMap = $bodyParamsMap = [];

        $queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];

        if ($gameId) {
            $bodyParamsMap[] = ['key' => 'game_id', 'value' => $gameId];
        }

        if ($language) {
            $bodyParamsMap[] = ['key' => 'broadcaster_language', 'value' => $language];
        }

        if ($title) {
            $bodyParamsMap[] = ['key' => 'title', 'value' => $title];
        }

        return $this->patchApi('channels', $bearer, $queryParamsMap, $bodyParamsMap);
    }

startCommercial

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#start-commercial
     */
    public function startCommercial(string $bearer, string $broadcasterId, int $length): ResponseInterface
    {
        $bodyParamsMap = [];

        $bodyParamsMap[] = ['broadcaster_id' => $broadcasterId];

        $bodyParamsMap[] = ['length' => $length];

        return $this->postApi('channels/commercial', $bearer, [], $bodyParamsMap);
    }

createCustomReward

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#create-custom-rewards
     */
    public function createCustomReward(string $bearer, string $broadcasterId, array $bodyParams = []): ResponseInterface
    {
        $queryParamsMap = $bodyParamsMap = [];

        $queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];

        // Due to the large number of body parameters for this endpoint, please supply an array for the $bodyParams parameter
        foreach ($bodyParams as $key => $value) {
            $bodyParamsMap[] = ['key' => $key, 'value' => $value];
        }

        return $this->postApi('channel_points/custom_rewards', $bearer, $queryParamsMap, $bodyParamsMap);
    }

updateCustomReward

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#update-custom-reward
     */
    public function updateCustomReward(string $bearer, string $broadcasterId, string $id, array $bodyParams = []): ResponseInterface
    {
        $queryParamsMap = $bodyParamsMap = [];

        $queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];

        $queryParamsMap[] = ['key' => 'id', 'value' => $id];

        // Due to the large number of body parameters for this endpoint, please supply an array for the $bodyParams parameter
        foreach ($bodyParams as $key => $value) {
            $bodyParamsMap[] = ['key' => $key, 'value' => $value];
        }

        return $this->patchApi('channel_points/custom_rewards', $bearer, $queryParamsMap, $bodyParamsMap);
    }

updateRedemptionStatus

    /**
     * @throws GuzzleException
     * @link https://dev.twitch.tv/docs/api/reference#update-redemption-status
     */
    public function updateRedemptionStatus(string $bearer, string $broadcasterId, string $rewardId, array $ids = [], string $status): ResponseInterface
    {
        $queryParamsMap = $bodyParamsMap = [];

        $queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];

        $queryParamsMap[] = ['key' => 'reward_id', 'value' => $rewardId];

        foreach ($ids as $id) {
            $queryParamsMap[] = ['key' => 'id', 'value' => $id];
        }

        $queryParamsMap[] = ['key' => 'status', 'value' => $status];

        return $this->patchApi('channel_points/custom_rewards/redemptions', $bearer, $queryParamsMap, $bodyParamsMap);
    }

what bearer token is twitch new api looking ?

Hello, i'm using the last version of this library and i'm trying to get some of the user data.

case : We have a acces token to a twitch user account after the user enable authentication, we then try to use your library to access his data

        $helixGuzzleClient = new HelixGuzzleClient($clientId);
        $apiClient = new NewTwitchApi($helixGuzzleClient, $clientId, $client_secret);
        $apiClient->getUsersApi()->getUserByUsername($accessToken, $name);

but the call always end up in failure

Client error: `GET https://api.twitch.tv/helix/users?login=name` resulted in a `401 Unauthorized` response:
{"error":"Unauthorized","status":401,"message":"Invalid OAuth token"}

My question is what's the value expect for the bearer token ?

Ensure Helix API allows authentication for all Endpoints

I haven't had a chance to check all of the endpoints and I will when I can, but I wanted to open this to keep us all on alert that all Helix endpoints require authentication now, need to ensure this flows through all the endpoints we have in the wrapper

Make API Requests with bearer token for Authenticated Requests

I would like to be able to make authenticated requests to the NewTwitch API via a bearer token. This seems to be allowed by the callApi() method by passing it in as a method parameter:

    protected function callApi(string $uriEndpoint, array $queryParamsMap = [], string $bearer = null): ResponseInterface
    {
        $request = new Request(
            'GET',
            sprintf('%s%s', $uriEndpoint, $this->generateQueryParams($queryParamsMap)),
            $bearer ? ['Authorization' => sprintf('Bearer %s', $useBearer)] : []
        );

        return $this->guzzleClient->send($request);
    }

However, when this method is wrapped with Resource endpoint classes, this feature is not used. For instance in the GamesApi the getGames() method looks like:

    public function getGames(array $ids = [], array $names = []): ResponseInterface
    {
        $queryParamsMap = [];
        foreach ($ids as $id) {
            $queryParamsMap[] = ['key' => 'id', 'value' => $id];
        }
        foreach ($names as $name) {
            $queryParamsMap[] = ['key' => 'name', 'value' => $name];
        }

        return $this->callApi('games', $queryParamsMap);
    }

Hence, I can't make a request using this method with my bearer token.

I feel like this authentication could/should be handled for the NewTwitch library. Where are bearer token can be requested from the TwitchApi, stored for later use, and applied to all API calls automatically. When a token is about to expire, I feel the TwitchApi should just refresh the token transparently without each user of the library having to write their own token handler.

I wouldn't mind working on implementing this, but it would be somewhat of a refactor to implement. So, I wanted to reach out so we could get on the same page about this functionality.

getStreams Improvements

  • Discontinue support for community_id
  • Add function helper for Game IDs, Languages
  • Allow first, after, before in helper functions?

Rename callApi to getApi

With put, post, and delete being the other methods, we should really name this one get. Not now, of course. That will be a breaking change. We can do it for the next major release. Please ticket? :-)

Originally posted by @echosa in #91 (comment)

Streams::getLiveStreams channel attribute

The channel variable ist checked for string but used in the foreach loop afterwards resulting in

PHP Warning:  Invalid argument supplied for foreach() in ...nicklaw5/twitch-api-php/src/Api/Streams.php on line 60

Review implementation of subscriptions

We have two functions making calls to subscription, this may be more ideal for code readability, however traditionally we do helper functions that call to the main function so if a call breaks we only have to update one and avoid breaking any other functions. Consider an adjustment in the code base.

Unsubscribe

subscribe function in webhook creation is hard coded to 'subscribe' mode. Is removing subscriptions coming at some point?

Add missing New Twitch API endpoints

startCommercial does not work

Based on the documentation, these are meant to be body parameters, not URL parameters. Opening this issue to resolve this bug.

Issue with getUserByAccessToken

I just installed this lib and trying to figure out how it works.
I want to get user info via a access token and did this:

$options = [
	'client_id' => $client_id
];

$twitchApi = new \TwitchApi\TwitchApi($options);
$user = $twitchApi->getUserByAccessToken($token->access_token);
var_dump($user);

However I just get an 500 error when doing this. Is this the correct usage?

Twitch API Discord

Hi @nicklaw5 (CC @echosa)

I've spoken with a Moderator in the Twitch API Discord (https://discord.gg/8NXaEyV) and they want to add both this and the Go Library (https://github.com/nicklaw5/helix) for the Twitch API as a resource in their server but they make the project owner and collaborators the owners of the channel, so you two would need to be in there and agree to have it added. I wanted to share this here so you can get into this Discord and reach out to Orangutan so he can complete this process.

Thank you,
Brandin.

Add PHP 8.0 Support in GHA

We need to begin testing PHP 8.0 in the specs, this should be added (PRs previously failed with this, wasn't debugged at the time)

getChannelInfo is duplicated

getChannelInfo is used in both the Channels and Streams. It looks like at some point Twitch moved it out of the Streams API and into another, it should be removed from the Streams API.

Update README

The README is out of date and should be updated. A lot has changed between when I last updated it and the current library version (3.1.0 at the time of this issue's creation).

Changes could include, but are not limited to:

  • Bearer requirement explanation
  • Code example(s)
  • Maybe refer to "New Twitch API" as just "Twitch API" now that Twitch seems to have changed the name on their end? (I sort of regret namespacing to NewTwitchAPI now, but it's not a big deal. It's clear enough, for now. :-) )
  • Is this paragraph still applicable?

The New Twitch API client is still being developed and is currently incomplete. The endpoints that are implemented are usable, but not all endpoints have been implemented yet. If an endpoint you need is missing, incomplete, or not working correctly, please report it or fix it if you can and create a PR for it.

  • Is the old Kraken API still available for use/allowed by Twitch? Should we remove it from the README to encourage not using it? Speaking of which, but not for this issue, are we approaching the time to remove it from the code? It would still be available in version <=3.1, if anyone still requires it. If we want to do this, it should be a separate issue/PR. (cc @nicklaw5)

cc @brandinarsenault

Update Travis CI to run new processes

#22 introduces a couple of new dev tools, namely phpspec and php-cs-fixer. We should get CI to run at least phpspec, if not also php-cs-fixer, once that PR is merged.

Add Root /kraken Enpoint

The /kraken Endpoint identifies if an OAuth token is still valid.

Documentation: https://dev.twitch.tv/docs/v5/guides/using-the-twitch-api/#requests

Details:

GET https://api.twitch.tv/kraken (with OAuth Authorization)

VALID Response

{
  "token": {
    "valid": true,
    "authorization": {
      "scopes": [
        "user_read"
      ],
      "created_at": "2017-04-24T14:09:17Z",
      "updated_at": "2017-04-24T14:09:17Z"
    },
    "user_name": "...",
    "user_id": "...",
    "client_id": "..."
  },
}

INVALID Response

{
  "token": {
    "valid": false,
    "authorization": null
  }
}

Create Missing Specs for Ads and Clips Api

As per PR #66 we need Specs for the new Ads and Clips API - low priority but will get this done with time

Specs required:

  • Ads->ALL
  • Bits->getBitsLeaderboard
  • Clips->ALL
  • Entitlements->getEntitlementGrantsUploadURL
  • HypeTrain->ALL
  • Moderation->ALL
  • Search->ALL
  • Streams->SOME
  • Subscriptions->ALL
  • Users->SOME
  • Videos->ALL
  • Webhooks->SOME?

Videos and Clips

Hi there,

I know, there is another Ticket with "missing Endpoints in NewAPI".
Nevertheless, is it likely, that you will add the Endpoints /videos and /clips for NewAPI anytime soon? Those are basically the most important Endpoints for us.

Thanks a lot!
Christoph

Fatal error: Uncaught Error: Class 'HelixGuzzleClient' not found

Some help im lost, i dont know what to do
Error:

Fatal error: Uncaught Error: Class 'HelixGuzzleClient' not found in C:\xampp\htdocs\Zaludov\redirect.php:29 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Zaludov\redirect.php on line 29

File redirect.php:


require 'vendor/autoload.php';
require_once('lib/twitchApi/HelixGuzzleClient.php');
require_once('lib/twitchApi/NewTwitchApi.php');
include_once('lib/urlGen.php');
include_once('lib/Config.php');

$urlGen = new urlGen;

echo '<a href="'.$urlGen->generateURL().'">Authenticate Me</a><br/>';

if(isset($_GET['error'])){
    echo "error: " . $_GET['error'] . "<br>";
    if(isset($_GET['error_description'])){
        echo "error description: " . $_GET['error_description'] . "<br>";
    }
}
if(!isset($_GET['code'])){
    echo "code not set" . "<br>";
    return;
}

$conf = new Config();
$accessToken = $_GET['code'];

// The Guzzle client used can be the included `HelixGuzzleClient` class, for convenience.
// You can also use a mock, fake, or other double for testing, of course.
$helixGuzzleClient = new HelixGuzzleClient($conf->getClientId());

// Instantiate twitchApi. Can be done in a service layer and injected as well.
$newTwitchApi = new NewTwitchApi($helixGuzzleClient, $conf->getClientId(), $conf->getClientSecret());

try {
    // Make the API call. A ResponseInterface object is returned.
    $response = $newTwitchApi->getUsersApi()->getUserByAccessToken($accessToken);

    // Get and decode the actual content sent by Twitch.
    $responseContent = json_decode($response->getBody()->getContents());

    // Return the first (or only) user.
    $user = $responseContent->data[0];
} catch (GuzzleException $e) {
    // Handle error appropriately for your application
    exit("error occured");
}

print_r($user);

directory: https://i.imgur.com/xIN4Jsb.png

PHPDocs

Love how detailed the PHPDocs are, thank you - one minor issue is that json is not a valid @return type. Instead, it's many instances should be string

PHPStorm, in particular, will cry about this when inheriting PHPDocs (making a wrapper using this library)

If you agree I'm happy to PR in the changes, thanks

getStreamTags is duplicated

getStreamTags is used in both the Tags and Streams. It looks like at some point Twitch moved it out of the Streams API and into another, it should be removed from the Streams API.

Complete Endpoint Coverage

Below is a list that we will maintain of missing endpoints including reasons they are blocked (if any) and our current coverage. If you wish to contribute for any of these, please submit a pull request. Our biggest blocker is Body Parameters. This was attempted in PR #94 but did not work so was moved into Issue #98.

Current Endpoint Coverage

Section Documented Library Coverage
Ads 1 0 0%
Analytics 2 2 100%
Bits 3 3 100%
Channels 3 2 67%
Channel Points 6 3 50%
Clips 2 2 100%
Entitlements 3 3 100%
EventSub 3 0 0%
Games 2 2 100%
HypeTrain 1 1 100%
Moderation 6 4 67%
Polls 3 1 33%
Predictions 3 1 33%
Search 2 2 100%
Streams 5 7 140%
Subscriptions 2 3 150%
Tags 3 2 67%
Teams 2 2 100%
Users 11 10 91%
Videos 2 2 100%
Webhooks 1 1 100%

Missing Endpoints

Section Endpoint Blocker
Ads Start Commercial Body Parameters
Channels Modify Channel Info Body Parameters
Channel Points Create Custom Rewards Body Parameters
Channel Points Update Custom Reward Body Parameters
Channel Points Update Redemption Status Body Parameters
EventSub Create EventSub Subscription Body Parameters
EventSub Delete EventSub Subscription None
EventSub Get EventSub Subscription None
Moderation Check AutoMod Status Body Parameters
Moderation Manage Held AutoMod Messages Body Parameters
Polls Create Poll Body Parameters
Polls End Poll Body Parameters
Predictions Create Prediction Body Parameters
Predictions End Prediction Body Parameters
Streams Create Stream Marker Body Parameters
Tags Replace Stream Tags Body Parameters
Users Update User Extensions Documentation

Proper way to make server-to-server calls

Ever since Twitch made a change last year, I've been having a problem with server to server calls returning 401 Unauthorized - OAuth token is missing

Is this library updated to handle this type of calls in order to get access tokens? Or do changes still need to be made for it? It looks like the oauth library can handle it, but it doesn't look like NewTwitchApi is using it.

Use string instead of int for Twitch IDs

As pointed out in Discord and confirmed in the NewTwitchApi docs, Twitch IDs are handled as strings, even though at the moment they seem to only be integer values. I assume this is for future-proofing. I erroneously made all the IDs act as integers via strict typing in the NewTwitchApi code. Sorry! This needs to be fixed.

Name to ID

Could you add the endpoint for name to id translations?

This would be:

https://api.twitch.tv/kraken/users?login={name}

(v5 API)

Issue with the $game parameter in Clips::getTopClips.

There's an issue with the $game parameter validation. Right now, it shows:

if ($count = count(explode(',', $game) > 10)) {

while it should be

if ($count = count(explode(',', $game)) > 10) { .

I'll send a PR shortly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.