项目作者: chipslays

项目描述 :
🎮 WIP: Steam Client for manage account, trade offers and more.
高级语言: PHP
项目地址: git://github.com/chipslays/steam-client.git
创建时间: 2020-11-13T19:41:24Z
项目社区:https://github.com/chipslays/steam-client

开源协议:MIT License

下载


WIP: PHP Steam Client

Work in progress

Installation

  1. $ composer require chipslays/steam-client

Example

Simple auth in CLI:

  1. // steam.php
  2. use Steam\Auth;
  3. use Steam\Client;
  4. require 'vendor/autoload.php';
  5. $client = new Client([
  6. 'username' => 'gaben',
  7. 'password' => 'hackmedaddy',
  8. 'sessionDir' => __DIR__ . '/storage/sessions',
  9. ]);
  10. $tryAuthCount = 0;
  11. if (!$client->isLoggedIn()) {
  12. $auth = $client->auth();
  13. while ($auth['code'] !== Auth::SUCCESS) {
  14. if (++$tryAuthCount >= 5) {
  15. throw new Exception('To many auth fails. For this you can get banned by IP if you continue.');
  16. }
  17. switch ($auth['code']) {
  18. case Auth::CAPTCHA:
  19. cli()->yellow()->out($auth['response']->get('message'));
  20. $captchaLink = $client->getCaptchaLink();
  21. cli()->yellow()->out($captchaLink);
  22. $input = cli()->input('>>> Enter captcha code:');
  23. $captchaResolveText = $input->prompt();
  24. $client->setCaptchaText($captchaResolveText);
  25. $auth = $client->auth();
  26. break;
  27. case Auth::EMAIL:
  28. $input = cli()->input('>>> Enter e-mail code:');
  29. $emailCode = $input->prompt();
  30. $client->setEmailCode($emailCode);
  31. $auth = $client->auth();
  32. break;
  33. case Auth::TWO_FACTOR:
  34. cli()->yellow()->out($auth['response']->get('message'));
  35. $input = cli()->input('>>> Enter 2FA code:');
  36. $twoFactorCode = $input->prompt();
  37. $client->setTwoFactorCode($twoFactorCode);
  38. $auth = $client->auth();
  39. case Auth::FAIL:
  40. print_r($auth);
  41. throw new Exception('Fail auth.');
  42. break;
  43. case Auth::BAD_RSA:
  44. throw new Exception('Fail RSA');
  45. break;
  46. case Auth::THROTTLE:
  47. throw new Exception($auth['response']->get('message'));
  48. break;
  49. case Auth::UNEXPECTED:
  50. print_r($auth);
  51. throw new Exception('Unexpected error 1');
  52. break;
  53. case Auth::BAD_CREDENTIALS:
  54. cli()->lightRed()->out($auth['response']->get('message'));
  55. $input = cli()->confirm('Want to enter new credentials?');
  56. if (!$input->confirmed()) {
  57. cli()->lightRed()->out('Client has been stopped.');
  58. exit;
  59. }
  60. $username = cli()->input('>>> Enter username:')->prompt();
  61. $password = cli()->password('>>> Enter password:')->prompt();
  62. $client->setUsername($username);
  63. $client->setPassword($password);
  64. $auth = $client->auth();
  65. break;
  66. default:
  67. throw new Exception("Unexpected error 2");
  68. break;
  69. }
  70. }
  71. }
  72. /** We are now logged in */
  73. $balance = $client->market()->getBalance();
  74. print_r($balance);
  75. /** Output */
  76. Array
  77. (
  78. [raw] => 13,37 pуб.
  79. [clean] => 13.37
  80. )
  1. php steam.php