dev-master
9999999-devLaravel twitch api
MIT
The Requires
The Development Requires
by Paul Bele
Wallogit.com
2017 © Pedro Peláez
Laravel twitch api
Laravel Twittch restful api. An implementation of the twitch restful api V3 provided by Twitch.tv Documentation of the API can be found at Twitch restful api link, (*1)
Require the package in composer.json :, (*2)
"skmetaly/laravel-twitch-restful-api": "dev-master"
In config/app.php add providers, (*3)
'Skmetaly\TwitchApi\Providers\TwitchApiServiceProvider'
In aliases, (*4)
'TwitchApi'=>'Skmetaly\TwitchApi\Facades\TwitchApiServiceFacade'
Publish the config, (*5)
php artisan vendor:publish --force
Create a twitch application ( in your twitch settings page, Connections tab ) Create a client secret Add both client secret, client id to the twitch-api.php config, (*6)
Change the scopes that the application needs to better suit your needs, (*7)
The api provides both non-authenticated and authenticated requests, (*8)
Twitch api uses OAuth 2.0 protocol for authentication., (*9)
This API uses the Authorization Code Flow., (*10)
First step for authenticating a user is to send him to the twitch authentication URL, (*11)
php
public function authenticate()
{
return Redirect::to(TwitchApi::authenticationURL());
}
Keep in mind that the api uses the config set in twitch-api.redirect_url for redirecting after authentication, (*12)
After the user accepted the scopes and authorised your app, it will be redirected at the value set in config('twitch-api.redirect_url'), (*13)
A sample of handling the redirect :, (*14)
```php public function redirect() { $code = Input::get('code');, (*15)
$token = TwitchApi::requestToken($code); }
```, (*16)
You need to persist both the username and token associated with it to use all of the authenticated requests, (*17)
Laravel twitch api
MIT