Download the PHP package romanzipp/laravel-twitch without Composer
On this page you can find all versions of the php package romanzipp/laravel-twitch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download romanzipp/laravel-twitch
More information about romanzipp/laravel-twitch
Files in romanzipp/laravel-twitch
Package laravel-twitch
Short Description Twitch PHP Wrapper for Laravel
License MIT
Informations about the package laravel-twitch
Laravel Twitch
PHP Twitch Helix API Wrapper for Laravel 5+
⚠️ Changes on May 01, 2020
Since May 01, 2020, Twitch requires all requests to contain a valid OAuth Access Token. This can be achieved by requesting an OAuth Token using the Client Credentials Flow.
If you don't handle this by yourself, be sure to enable the built-in Access Token generation feature via the oauth_client_credentials.auto_generate
configuration entry.
You will need define a valid Client ID and Client Secret via your config or the available setters! See the full config for more details.
Table of contents
- Installation
- Configuration
- Examples
- Documentation
- Upgrading
- Development
Installation
Configuration
Copy configuration to project:
Add environmental variables to your .env
:
If you want to use the EventSub with the Webhook transport, then you are required to define a secret. This secret is a string between 10 and 100 characters.
Examples
Basic
Setters
OAuth Tokens
OAuth Client Credentials Flow
Since May 01, 2020, every request requires an OAuth token which can be issued using the OAuth Client Credentials Flow.
Pagination
The Twitch API returns a paginator
field with paginated results like /streams
, /follows
or /games
. To jump between pages, the given cursor must be appended to the following query using the direction attributes after
or before
.
In this example, we will fetch a set of streams and use the provided cursor to switch to the next/previous set of data.
❗️ To prevent infinite loops or errors, use the Result::hasMoreResults()
method to check if there are more results available.
Facade
Pagination Loop Example
This example fetches all Twitch Games and stores them into a database.
Insert user objects
The new API does not include the user objects in endpoints like followers or bits.
You can just call the insertUsers method to insert all user data identified by from_id
into from_user
New Result data:
Defining EventSub Handlers
By default, the EventSub webhook controller will automatically handle all EventSub notification and revocation calls; however, if you have additional webhook events you would like to handle, you may do so by extending the EventSub webhook controller.
To ensure your application can handle EventSub webhooks, be sure to configure the webhook callback url in the transport payload.
Your controller's method names should correspond to Laravel Twitch's controller conventions. Specifically, methods
should be prefixed with handle
, suffixed with Notification
and the "camel case" name of the EventSub Type you wish
to handle. For example, if you wish to handle the channel.follow
type, you should add a
handleChannelFollowNotification
method to the controller:
Next, define a route to your EventSub webhook controller within your application's routes/api.php
file.
Create EventSub Subscription
Important: When creating a subscription, you must specify a secret for purposes of verification, described above in “Configuration”. This secret is automatically attached to the webhook transport if it is not explicitly defined.
List EventSub Subscription
Delete EventSub Subscription
Twitch Extension Guard
1. Create TwitchUserProvider
Create app/Auth/TwitchUserProvider.php
:
2. Register TwitchUserProvider & TwitchExtensionGuard
Edit app/Providers/AuthServiceProvider.php
:
3. Make guard available in Laravel
Edit config/auth.php
:
Documentation
Twitch Helix API Documentation: https://dev.twitch.tv/docs/api/reference
Ads
Analytics
Bits
ChannelPoints
Channels
Charity
Chat
Clips
Entitlements
EventSub
Extensions
Games
Goals
HypeTrain
Moderation
Music
OAuth
Polls
Predictions
Raids
Schedule
Search
Streams
Subscriptions
Tags
Teams
Users
Videos
Webhooks
Whispers
Upgrading
Development
Run Tests
Generate Documentation
Join the Twitch Dev Discord!
All versions of laravel-twitch with dependencies
ext-json Version *
firebase/php-jwt Version ^6.2
guzzlehttp/guzzle Version ^7.0
illuminate/cache Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/console Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^7.0|^8.0|^9.0|^10.0|^11.0