relisoft/php-steam-user-library
Composer 安装命令:
composer require relisoft/php-steam-user-library
包简介
Steam PHP library for getting data from API
README 文档
README
This library may help someone who want to use steam API and use it to fetch user data. With few lines of code you can fetch everything about user.
Install:
composer require relisoft/php-steam-user-library
CONTENT:
- user summary
- friends
- game stats
- cache results
- recently played games
- inventory (with item details)
- login via steam
TODO:
- achievement
- trade support
How to use it?
HomepagePresenter
public function renderSingle() { $player = new Player("76561198151608925"); $request = new Request(); $request->getPlayerFriends($player,2); $request->getPlayerRecentlyPlayedGames($player); $request->getPlayerInventory($player,Games::CSGO); Dumper::dump($player); }
But what we do if we need cache results?
We will use new functions and we will load full user profile and system automaticly cache it. It's cache function call so if some result will be different it will automaticly reload data.
public function renderSingle() { $player = new Player("76561198151608925"); $request = new Request(); $player = $request->getFullData($player); // This function will load full profile (profile, recent games, friends, inventory) $this->template->items = $player->getInventory()->getData(); }
Dump:
Getting / Setting data
Every variable did you see above have get and set function within you can set every variable and get it too.
$player->getState() $player->getLastlogoff() $player->getFriends()
Persona state
Persona state is one class with you can translate value from API to english language or edit to html return value.
Relisoft\Steam\Src\API\PersonaState::getVerbState($player->getPersonaState())
Login
Login button:
For this purpose i created Button class with two static function whitch will return source link to img.
<div class="container">
<a href="{link login!}"><img src="{Relisoft\Steam\Src\Login\Button::rectangle()}"></a>
</div>
Relisoft\Steam\Src\Login\Button::rectangle()
Relisoft\Steam\Src\Login\Button::square()
Login function
For this i created class Login whitch use $session to store user data. You have to add your source of $session or use default $_SESSION. I did this because i am using nette/http in my all project with better session api.
Create instance
$this->login = new Login($this->session->getSection("steam")); OR $this->login = new Login($_SESSION);
Usage
public function handleLogin() { $login = $this->login; if($login->isLogged()) // If is use logged in { $this->flashMessage("User is logged."); //Flash message like echo $this->redirect("single",$this->session->getSection("steam")->user); // This you can edit for your purpose } else { $object = $login->auth(); // Auth user and return states if($object) //IF SUCCESS RETURN STEAM ID { $this->flashMessage("successfuly logged in $object"); //Echo some text $this->redirect("single",$object); // Redirect to another page with parameter $object -> returning STEAM ID } elseif($object == $login::FAILED) { $this->flashMessage("Steam is not logged in!"); //Echo that's failed $this->redirect("this"); //Redirect } elseif($object == $login::CANCEL) //Echo that's your cancel process { $this->flashMessage("Cancel by user"); $this->redirect("this"); } } }
Login states:
const CANCEL = "cancel"; const SUCCESS = "success"; const FAILED = "failed";
Depency:
- nette/utils
- nette/neon
- nette/caching
- PHP 5.4+
relisoft/php-steam-user-library 适用场景与选型建议
relisoft/php-steam-user-library 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 relisoft/php-steam-user-library 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 relisoft/php-steam-user-library 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-25