Пример #1
0
<?php

/**
 * Created by PhpStorm.
 * User: Joel
 * Date: 2015-12-28
 * Time: 2:25 AM
 */
require '../vendor/autoload.php';
use waylaidwanderer\SteamCommunity\Enum\LoginResult;
use waylaidwanderer\SteamCommunity\SteamCommunity;
date_default_timezone_set('America/Los_Angeles');
$settings = json_decode(file_get_contents('settings.json'));
$steam = new SteamCommunity($settings->username, $settings->password, dirname(__FILE__) . $settings->cookieFilesDir);
$loginResult = $steam->doLogin();
while ($loginResult != LoginResult::LoginOkay) {
    if ($loginResult == LoginResult::Need2FA) {
        $authCode = ask('Enter 2FA code: ');
        $steam->setTwoFactorCode($authCode);
        $loginResult = $steam->doLogin();
    } else {
        if ($loginResult == LoginResult::NeedEmail) {
            $authCode = ask('Enter Steam Guard code from email: ');
            $steam->setEmailCode($authCode);
            $loginResult = $steam->doLogin();
        } else {
            break;
        }
    }
}
if ($loginResult == LoginResult::LoginOkay) {
<?php

/**
 * This is an example of how you can use PHP-SteamCommunity.
 * This file is meant to be run via php-cli (the command line) but can be adapted to run on a webserver as well.
 */
require '../vendor/autoload.php';
defined('STDIN') or define('STDIN', fopen("php://stdin", "r"));
use waylaidwanderer\SteamCommunity\Enum\LoginResult;
use waylaidwanderer\SteamCommunity\MobileAuth\WgTokenInvalidException;
use waylaidwanderer\SteamCommunity\SteamCommunity;
date_default_timezone_set('America/Los_Angeles');
$settings = json_decode(file_get_contents('settings.json'), true);
$steam = new SteamCommunity($settings, dirname(__FILE__));
$loginResult = $steam->doLogin();
while ($loginResult != LoginResult::LoginOkay) {
    if ($loginResult == LoginResult::Need2FA) {
        if ($steam->mobileAuth() == null) {
            $authCode = ask('Enter 2FA code: ');
            $steam->setTwoFactorCode($authCode);
        } else {
            $authCode = $steam->mobileAuth()->steamGuard()->generateSteamGuardCode();
            $steam->setTwoFactorCode($authCode);
            writeLine('Generated Steam Guard code: ' . $authCode);
        }
        $loginResult = $steam->doLogin();
    } else {
        if ($loginResult == LoginResult::NeedEmail) {
            $authCode = ask('Enter Steam Guard code from email: ');
            $steam->setEmailCode($authCode);
            $loginResult = $steam->doLogin();