解密 / twitch-sdk
PHP版的TwitchTV API SDK
2.1.4
2020-05-07 13:38 UTC
Requires
- php: >=5.3.0
- ext-curl: *
Requires (Dev)
- jakub-onderka/php-console-highlighter: ^0.3.2
- jakub-onderka/php-parallel-lint: ^0.9.2
- phpunit/phpunit: 4.3.*
- squizlabs/php_codesniffer: ^2.7
Replaces
- ritero/twitch-sdk: 2.*
README
这是非官方的 TwitchTV SDK for PHP,它是由于 https://github.com/jofner/Twitch-SDK 已停止维护而创建的分支。这个版本将至少进行基本修复,并已在生产环境中运行。#therebedragons #v5
需求
PHP版的TwitchTV SDK需要PHP 5.3.0或更高版本,并且启用了cURL扩展。
安装
安装TwitchTV SDK的最佳方式是使用Composer。
使用Composer下载包
$ composer require 'decrypted/twitch-sdk:2.1.*'
下载的包包含src
目录。该目录包含PHP版TwitchTV SDK的源代码。这是您部署应用程序所需的所有目录。
入门
基本功能遵循标准命名约定(user*、channel*等。) - 例如userGet()
。认证功能具有auth*前缀,如authUserGet()
。
在您的项目中初始化SDK
使用自动加载器(框架等。)
use \jofner\SDK\TwitchTV\TwitchSDK; $twitch = new TwitchSDK; ...
不使用自动加载器
require '/path/to/libs/jofner/SDK/TwitchTV/TwitchSDK.php'; require '/path/to/libs/jofner/SDK/TwitchTV/TwitchSDKException.php'; use \jofner\SDK\TwitchTV\TwitchSDK; use \jofner\SDK\TwitchTV\TwitchSDKException; $twitch = new TwitchSDK; ...
用法
基本用法(仅公共函数)
$twitch = new TwitchSDK; $channel = $twitch->channelGet('channelname'); ...
认证函数用法
$twitch_config = array( 'client_id' => 'your_twitch_app_client_id', 'client_secret' => 'your_twitch_app_client_secret', 'redirect_uri' => 'your_twitch_app_redirect_uri', ); $twitch = new TwitchSDK($twitch_config); $loginURL = $twitch->authLoginURL('user_read'); ...
更多示例将很快在Wiki页面上找到。
错误:curl SSL证书问题:证书链中的自签名证书
如果您遇到此错误,您可能CA根证书已过时。请确保您的php.ini中已设置curl.cainfo = "..."的证书路径
您可以从这个网站获取cacert.pem https://curl.haxx.se/docs/caextract.html
许可证
有关许可证信息,请参阅LICENSE.md文件