corbpie/twitch-api-class 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

corbpie/twitch-api-class

Composer 安装命令:

composer require corbpie/twitch-api-class

包简介

A PHP Twitch API wrapper

README 文档

README

Updated for OAuth usage!

Feature packed, easy to use PHP class for the latest Twitch API.

You will need your free Twitch client id to use, see here to obtain.

To get your authorization code see here.

This class will automatically refresh access token once it expires!

Features

  • Get top streams
  • Get top streams for game
  • Get popular games
  • Get details for username
  • Get user id for username
  • Get users emotes
  • Get emote image
  • Get chat for a VOD
  • Check if user is live
  • Get users streaming game
  • Get users streaming title
  • Get users streaming id
  • Get streaming thumbnail
  • Get users view count
  • Get users streaming description
  • Get users stream start time
  • Get users stream tags
  • Get clips for game
  • Get users clips
  • Get game name for game id
  • Get game artwork for game id

Usage

Fetch with composer:

composer require corbpie/twitch-api-class

To use:

require_once('vendor/autoload.php');

use Corbpie\TwitchApiClass\twitchWrapper;

$call = new twitchWrapper();

Add your Twitch client id and client secret into src/twitchWrapper.php (lines 7-8)

Add your redirect URI info (line 10)

Change the token filename constant, however keep it as a .txt extension (line 11)

Access code can be obtained with

echo $call->accessCodeUrl();

Upon going to the link You will find the access code in the URL:

http://localhost/?code=THEISACCESSCODE

Calls

Get current top (view count) streams array

$call->getTopStreams();

Get current top (view count) streams for a game array

$call->getGameTopStreams($gameid);

Get top (view count) streamer for a game string

$call->getGameTopStreams($gameid);
echo $call->getTopStreamerForGame();

Get viewer count for the top stream for a game string

$call->getGameTopStreams($gameid);
echo $call->getTopViewersForGame();

Get top games array

(Good way to get gameid's)

$call->getTopGames();

Get details for username array

$call->getUserDetails($username);

Get user id for username string

$call->getUserDetails($username);
$user_id = $call->idForUser();

Get emotes for username array

$call->getUserEmotes($username);

Get image for emote id string

$call->emoteImage($emoteid);

Get chat for VOD array

$call->chatForVod($vod_id, $offset);

Get users stream details (If live) array

$call->getUserStream($username);

Check if a user is live and streaming boolean

$call->getUserStream($username);
$call->userIsLive();//true for live | false for not live

If user is streaming:

Get game id string

$call->streamGameId();

Get viewer count string

$call->streamViewers();

Get stream title string

$call->streamTitle();

Get stream id string

$call->streamId();

Get stream start time string

$call->streamStart();

Get stream thumbnail string

$call->streamThumbnail();

Get stream thumbnail array

$call->getStreamTags($streamid);

Get top clips for game id array

$call->getGameClips($gameid);

Get users top clips array

$call->getUserClips($user);

Get users videos (most recent first) array

$call->getUserVideos($user);

Get users videos for game id array

$call->getUserVideosForGame($user, $game_id);

Get game data for game id array

$call->getGameData($game_id);

Get game name string

$call->getGameData($game_id);
$game_name = $call->gameName();

Get game artwork string

$call->getGameData($game_id);
$game_name = $call->gameArtwork();

Get game artwork string

$call->getGameData($game_id);
$game_name = $call->gameArtwork();

Custom array access string

//array return call here Eg:$call->getUserDetails('shroud');
$custom = $call->getCustom(0, 'type');

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固