allyans3 / protobuf-steam-auth
描述
v1.0.9
2023-11-12 19:41 UTC
Requires
- allegro/php-protobuf: ^0.12.4
- allyans3/php-steam-totp: ^1.0
- php-curl-class/php-curl-class: >=8.10.0
- ramsey/uuid: ^4.2
Requires (Dev)
- symfony/var-dumper: ^5.4
README
要使用此包,您需要安装PHP扩展
protobuf
。以下为安装说明。
关于Protobuf Steam Auth
此包提供了使用Google Protobuf授权到Steam的能力。支持PHP 7+和PHP 8+。
安装
- 在控制台中运行以下文本,从Packagist安装此包
composer require allyans3/protobuf-steam-auth
- 将
/vendor/allyans3/protobuf-steam-auth
目录下的protobuf-ext
文件夹复制到您的项目中
cp -a /vendor/allyans3/protobuf-steam-auth/protobuf-ext .
- 使用以下命令构建PHP扩展,选择
php 7
和php 8
(感谢Tankonyako)
cd protobuf-ext/php7 // For PHP 7
cd protobuf-ext/php8 // For PHP 8
对于Linux/Mac
phpize
./configure
make
make install
对于Windows,请查看此Youtube视频
- 将
extension=protobuf.so
行添加到您的php.ini文件中
用法
use SteamAuth\SteamAuth; require "vendor/autoload.php"; $auth = new SteamAuth('login', 'password', 'shared_secret'); // For proxy $auth->setProxy($proxy); // For WebBrowser $auth->login(); // or for MobileApp $auth->loginMobile(); // You can check if you are authorized $auth->isAuthorized(); // If auth `true` you can get cookies $auth->getCookies(); // or by host $auth->getCookiesByHost(); // Getting data for platform type $auth->getDataForPlatformType(1) // 1 => Steam Client, 2 => Web Browser, 3 => Mobile App // Updating `access_token` with `refresh_token` $auth->updateAccessToken($refreshToken) // Decoding JWT $auth->decodeJWT($token)
Cookie存储
默认情况下,Cookie保存在$cookieStorage
属性中,可以通过getCookies()
或getCookiesByHost()
方法检索。
可选,您可以在cookie_file
键中指定您的Cookie文件路径。
此外,您可以将Cookie作为数组发送到cookie_storage
键。
use SteamAuth\SteamAuth; require "vendor/autoload.php"; $cookieOptions = [ 'cookie_file' => 'path_to_cookie_file', 'cookie_storage' => [ "steamcommunity.com" => [ "sessionid" => "*******", "steamCountry" => "*******", "steamLoginSecure" => "*******" ], "store.steampowered.com" => [ "sessionid" => "*******", "steamLoginSecure" => "*******" ], "help.steampowered.com" => [ "sessionid" => "*******", "steamLoginSecure" => "*******" ], "steam.tv" => [ "sessionid" => "*******", "steamCountry" => "*******", "steamLoginSecure" => "*******" ], "checkout.steampowered.com" => [ "steamLoginSecure" => "*******" ] ] ]; $auth = new SteamAuth('login', 'password', 'shared_secret', $cookieOptions);
处理异常
use SteamAuth\SteamAuth; require "vendor/autoload.php"; $auth = new SteamAuth('login', 'password', 'shared_secret'); try { $auth->login(); } catch (\SteamAuth\Exceptions\SteamErrorException $e) { $e->getMessage(); } catch (\SteamAuth\Exceptions\SteamResponseException $e) { $e->getMessage(); }
代理
需要1.0.9或更高版本才能使用代理。
可以放在数组中的键
ip
+port
或domain_name
– 使用domain_name
进行代理轮换user
+pass
– 如果代理支持认证type
– 您可以传递表格中解释的常量变量或整数timeout
– 以秒为单位,默认无限connect_timeout
– 以秒为单位,默认无限user_agent
– 您的用户代理
示例
use SteamAuth\SteamAuth; require "vendor/autoload.php"; $proxy = [ 'ip' => '49.12.181.264', 'port' => 8000, 'user' => 'user', 'pass' => 'pass' ]; $auth = new SteamAuth('login', 'password', 'shared_secret'); $auth->setProxy($proxy); $auth->login();
支持
在问题跟踪器中报告错误。
许可
Protobuf Steam Auth是开源的Composer包,许可协议为MIT许可。