allyans3/protobuf-steam-auth

v1.0.9 2023-11-12 19:41 UTC

This package is auto-updated.

Last update: 2024-09-20 13:07:54 UTC


README

Protobuf-Steam-Auth

Latest Stable Version Total Downloads Visitors count License

要使用此包,您需要安装PHP扩展protobuf。以下为安装说明。

关于Protobuf Steam Auth

此包提供了使用Google Protobuf授权到Steam的能力。支持PHP 7+和PHP 8+。

安装

  1. 在控制台中运行以下文本,从Packagist安装此包
composer require allyans3/protobuf-steam-auth
  1. /vendor/allyans3/protobuf-steam-auth目录下的protobuf-ext文件夹复制到您的项目中
cp -a /vendor/allyans3/protobuf-steam-auth/protobuf-ext .
  1. 使用以下命令构建PHP扩展,选择php 7php 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视频

  1. 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 + portdomain_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许可