Skip to content

Commit df39580

Browse files
committed
Adding new methods and docs to L4 version.
1 parent 88dc550 commit df39580

File tree

4 files changed

+77
-14
lines changed

4 files changed

+77
-14
lines changed

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Steam
22

3-
[![Build Status](https://travis-ci.org/syntaxerrors/Steam.svg)](https://travis-ci.org/syntaxerrors/Steam)
4-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/syntaxerrors/Steam/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/syntaxerrors/Steam/?branch=master)
3+
[![Join the chat at https://gitter.im/syntaxerrors/Steam](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/syntaxerrors/Steam?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
5+
[![Build Status](https://travis-ci.org/syntaxerrors/Steam.svg?branch=Laravel4)](https://travis-ci.org/syntaxerrors/Steam)
6+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/syntaxerrors/Steam/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/syntaxerrors/Steam/?branch=Laravel4)
57
[![Latest Stable Version](https://poser.pugx.org/syntax/steam-api/v/stable.svg)](https://packagist.org/packages/syntax/steam-api)
68
[![Total Downloads](https://poser.pugx.org/syntax/steam-api/downloads.svg)](https://packagist.org/packages/syntax/steam-api)
79
[![License](https://poser.pugx.org/syntax/steam-api/license.svg)](https://packagist.org/packages/syntax/steam-api)
810

11+
**For Laravel 5, checkout the documentation on the [Laravel 5 branch](https://github.com/syntaxerrors/Steam).**
912

1013
This package provides an easy way to get details from the steam api service. The services it can access are:
1114

@@ -20,16 +23,16 @@ This package provides an easy way to get details from the steam api service. Th
2023
Begin by installing this package with composer.
2124

2225
"require": {
23-
"syntax/steam-api": "dev-master"
26+
"syntax/steam-api": "1.2.*"
2427
}
25-
28+
2629
Next, update composer from the terminal.
2730

2831
composer update syntax/steam-api
2932

3033
> Alternately, you can run "composer require syntax/steam-api:dev-master" from the command line.
3134
32-
Once that is finished, add the service provider to `app/config/app.php`
35+
Once that is finished, add the service provider to `config/app.php`
3336

3437
'Syntax\SteamApi\SteamApiServiceProvider',
3538

@@ -175,6 +178,21 @@ When instantiating the user class, you are required to pass a steamId or steam c
175178
Steam::user($steamId)
176179
```
177180

181+
#### ResolveVanityURL
182+
This will return details on the user from their display name.
183+
184+
##### Arguments
185+
186+
Name | Type | Description | Required | Default
187+
-----|------|-------------|----------|---------
188+
displayName| string | The display name to get the steam ID for. In `http://steamcommunity.com/id/gabelogannewell` it would be `gabelogannewell`. | Yes | NULL
189+
190+
```php
191+
$player = Steam::user($steamId)->ResolveVanityURL('gabelogannewell');
192+
```
193+
194+
> Example Output: [ResolveVanityURL](./examples/user/ResolveVanityURL.txt)
195+
178196
#### GetPlayerSummaries
179197
This will return details on the user.
180198

@@ -257,9 +275,10 @@ Returns a list of achievements for this user by app id.
257275
Name | Type | Description | Required | Default
258276
-----|------|-------------|----------|---------
259277
appId| int | The id of the game you want the user's achievements in | Yes |
278+
all| boolean | If you want all stats and not just the achievements set to true.| No | FALSE
260279

261280

262-
> Example Output: [GetUserStatsForGame](./examples/user/stats/GetUserStatsForGame.txt)
281+
> Example Output: [GetUserStatsForGame](./examples/user/stats/GetUserStatsForGame.txt) | [GetUserStatsForGame (all)](./examples/user/stats/GetUserStatsForGameAll.txt)
263282
264283
### App
265284
This area will get details for games.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
],
1111
"require": {
1212
"php": ">=5.4.0",
13-
"laravel/framework": "~5.0",
14-
"illuminate/html": "~5.0",
13+
"illuminate/support": "4.2.*",
14+
"laravel/framework": "4.2.*",
1515
"guzzle/guzzle": "3.9.2"
1616
},
1717
"require-dev": {

src/Syntax/SteamApi/Steam/User.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,37 @@ public function __construct($steamId)
1717
$this->steamId = $steamId;
1818
}
1919

20+
/**
21+
* Get the user_ids for a display name.
22+
*
23+
* @param null $displayName Custom name from steam profile link.
24+
*
25+
* @return mixed
26+
*
27+
* @throws UnrecognizedId
28+
*/
29+
public function ResolveVanityURL($displayName = null)
30+
{
31+
// This only works with a display name. Make sure we have one.
32+
if ($displayName == null) {
33+
throw new UnrecognizedId('You must pass a display name for this call.');
34+
}
35+
36+
// Set up the api details
37+
$this->method = __FUNCTION__;
38+
$this->version = 'v0001';
39+
40+
$results = $this->setUpClient(['vanityurl' => $displayName])->response;
41+
42+
// The message key is used when something goes wrong. If it exists, return it.
43+
if (isset($results->message)) {
44+
return $results->message;
45+
}
46+
47+
// Return the full steam ID object for the display name.
48+
return $this->convertId($results->steamid);
49+
}
50+
2051
/**
2152
* @param string $steamId
2253
*

src/Syntax/SteamApi/Steam/User/Stats.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
use Syntax\SteamApi\Client;
44
use Syntax\SteamApi\Containers\Achievement;
55

6-
class Stats extends Client {
6+
class Stats extends Client
7+
{
78

89
public function __construct($steamId)
910
{
@@ -22,7 +23,7 @@ public function GetPlayerAchievements($appId)
2223
$arguments = [
2324
'steamid' => $this->steamId,
2425
'appid' => $appId,
25-
'l' => 'english'
26+
'l' => 'english',
2627
];
2728

2829
// Get the client
@@ -43,7 +44,7 @@ public function GetGlobalAchievementPercentagesForApp($gameId)
4344
// Set up the arguments
4445
$arguments = [
4546
'gameid' => $gameId,
46-
'l' => 'english'
47+
'l' => 'english',
4748
];
4849

4950
// Get the client
@@ -52,7 +53,14 @@ public function GetGlobalAchievementPercentagesForApp($gameId)
5253
return $client->achievements;
5354
}
5455

55-
public function GetUserStatsForGame($appId)
56+
/**
57+
* @param $appId int Steam 64 id
58+
* @param $all bool Return all stats when true and only achievements when false
59+
*
60+
* @return mixed
61+
*/
62+
63+
public function GetUserStatsForGame($appId, $all = false)
5664
{
5765
// Set up the api details
5866
$this->method = __FUNCTION__;
@@ -62,18 +70,23 @@ public function GetUserStatsForGame($appId)
6270
$arguments = [
6371
'steamid' => $this->steamId,
6472
'appid' => $appId,
65-
'l' => 'english'
73+
'l' => 'english',
6674
];
6775

6876
// Get the client
6977
$client = $this->setUpClient($arguments)->playerstats;
7078

79+
// Games like DOTA and CS:GO have additional stats here. Return everything if they are wanted.
80+
if ($all === true) {
81+
return $client;
82+
}
83+
7184
return $client->achievements;
7285
}
7386

7487
protected function convertToObjects($achievements)
7588
{
76-
$cleanedAchievements = array();
89+
$cleanedAchievements = [];
7790

7891
foreach ($achievements as $achievement) {
7992
$cleanedAchievements[] = new Achievement($achievement);

0 commit comments

Comments
 (0)