Download the PHP package obnoxiousfrog/twitch-api without Composer
On this page you can find all versions of the php package obnoxiousfrog/twitch-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package twitch-api
Twitch Api
This is a PHP library to simplify working with the Twitch API.
PLEASE READ
It has come to my attention that this package may no longer be compatible with the recent Twitch API changes. Unfortunately, I do not have the time required to look into it at the moment. Hopefully, I will some day in the not too distant future, and maybe I'll even go ahead and re-write it completely. I will not offer support on any major feature requests or issues until then.
Please keep this in mind if you decide to use and/or rely on this package.
Thank you.
Installation
Install by running the following Composer command:
Example
Below is an example for authenticating the user, checking if the user is following and subscribed to the user obnoxiousfrog
, and if they are, they are greeted with a message. If not, an exception is thrown for logging, and/or redirecting the user to another page with an error message.
Documentation
TwitchApi\Application
This class implements the \TwitchApi\Contracts\Application
contract.
The entire API revolves around the Application
object.
client
is your Twitch application client id.
secret
is your Twitch application client secret (do not share this with anyone).
scopes
is an array of Twitch scopes.
redirect
is the Twitch application redirect url.
Below is an example of how this might look in a production environment.
Class Methods
Visibility | Method | Arguments | Return |
---|---|---|---|
public | __construct | string $client string $secret array $scopes string $redirect | void |
public | request | - | \TwitchApi\Contracts\Request |
public | bind | string $abstract, string $concrete | void |
public | instance | string $abstract, array $parameters [] | \StdClass |
public | make | string $abstract, array $parameters [] | \StdClass |
private | instantiate | string $concrete, array $parameters | \StdClass |
public static | api | - | string |
public static | client | - | string |
public static | secret | - | string |
public static | scopes | - | string |
public static | redirect | - | string |
TwitchApi\Authenticator
This class implements the \TwitchApi\Contracts\Authenticator
contract.
Class Methods
Visibility | Method | Arguments | Return |
---|---|---|---|
public | __construct | \TwitchApi\Contracts\Application $app | void |
public | authenticate | - | boolean |
public | user | - | \TwitchApi\Contracts\User |
public | channel | string $channel | \TwitchApi\Contracts\Channel |
public static | url | string $client null, string $redirect null, string $scopes null | string |
TwitchApi\User
This class implements the \TwitchApi\Contracts\User
contract.
Class Methods
Visibility | Method | Arguments | Return |
---|---|---|---|
public | __construct | \TwitchApi\Contracts\Application $app, \TwitchApi\Contracts\Response $token, \TwitchApi\Contracts\Response $user | void |
public | accessToken | - | string |
public | refreshToken | - | string |
public | id | - | integer |
public | - | string | |
public | name | - | string |
public | displayname | - | string |
public | logo | - | string |
public | bio | - | string |
public | timestamps | - | array |
public | isPartnered | - | boolean |
public | isSubscribed | string $streamer | boolean |
public | isFollowing | string $streamer | boolean |
TwitchApi\Channel
This class implements the \TwitchApi\Contracts\Channel
contract.
Class Methods
Visibility | Method | Arguments | Return |
---|---|---|---|
public | __construct | \TwitchApi\Contracts\Application $app, \TwitchApi\Contracts\User $user, string $channel | void |
public | get | - | \TwitchApi\Contracts\Response |
public | teams | - | array |
public | emoticons | - | array |
TwitchApi\Request
This class implements the \TwitchApi\Contracts\Request
contract.
Class Methods
Visibility | Method | Arguments | Return |
---|---|---|---|
public | __construct | \TwitchApi\Contracts\Application $app | void |
public | get | string $endpoint, array $parameters [], array $headers [] | \TwitchApi\Contract\Response |
public | post | string $endpoint, array $parameters [], array $headers [] | \TwitchApi\Contract\Response |
TwitchApi\Response
This class implements the \TwitchApi\Contracts\Response
contract.
Class Methods
Visibility | Method | Arguments | Return |
---|---|---|---|
public | __construct | \TwitchApi\Contracts\Application $app, string $response, array $request | void |
public | __get | string $property | mixed |
Using your own classes
Make sure your own classes implement the appropriate contract (you may find all the contracts below the title of each class documentation above), and then you may simply run the bind
method from the \TwitchApi\Application
object.
For example, the following would replace the TwitchApi User class with your own: