定制 skmetaly/laravel-twitch-restful-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skmetaly/laravel-twitch-restful-api

Composer 安装命令:

composer require skmetaly/laravel-twitch-restful-api

包简介

Laravel twitch api

README 文档

README

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

Installation

Require the package in composer.json :

"skmetaly/laravel-twitch-restful-api": "dev-master"

In config/app.php add providers

'Skmetaly\TwitchApi\Providers\TwitchApiServiceProvider'

In aliases

'TwitchApi'=>'Skmetaly\TwitchApi\Facades\TwitchApiServiceFacade'

Publish the config

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

Change the scopes that the application needs to better suit your needs

Usage

The api provides both non-authenticated and authenticated requests

Authentication

Twitch api uses OAuth 2.0 protocol for authentication.

This API uses the Authorization Code Flow.

First step for authenticating a user is to send him to the twitch authentication URL

   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

After the user accepted the scopes and authorised your app, it will be redirected at the value set in config('twitch-api.redirect_url')

A sample of handling the redirect :

   public function redirect()
   {
       $code = Input::get('code');

       $token = TwitchApi::requestToken($code);
   }

You need to persist both the username and token associated with it to use all of the authenticated requests

统计信息

  • 总下载量: 378
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-31