PhpGw2Api is a PHP wrapper for the GW2 API.
- PHP 5.3+
- cURL
require_once 'src/PhpGw2Api/Service.php';
// Instatiate a new service object and specify cache path and TTL settings
$service = new PhpGw2Api\Service(__DIR__ . '/cache', 3600);
// Set how to return the JSON
$service->returnAssoc(true);
// Query
$items = $service->getItems();
// Play around
$itemId = $items['items'][50];
$item = $service->getItemDetails(array('item_id' => $itemId));
var_dump($item);
Examples of use can be found here
If a cache directory is specified, the JSON response will be cached locally with the specified lifetime, or a default of 3600 seconds. You can specify cache settings in the following ways:
Upon instatiation:
$service = new PhpGw2Api\Service(__DIR__ . '/cache', 3600);
Using the fluent interface:
$service->setCacheDirectory(__DIR__ . '/cache')
->setCacheTtl(120)
->getItems();
Additionally, TTL may be specified on a per request basis:
$service->getItems(array(), 60);
The following draws reference from https://forum-en.guildwars2.com/forum/community/api/API-Documentation
Optional parameters: world_id, map_id, event_id
$service->getEvents(array('world_id' => 1001));
Optional parameters: lang
$service->getEventNames(array('lang' => 'fr'));
Optional parameters: lang
$service->getMapNames(array('lang' => 'fr'));
Optional parameters: lang
$service->getWorldNames(array('lang' => 'fr'));
$service->getMatches();
Requred parameters: match_id
$service->getMatchDetails(array('match_id' => '2-3'));
Optional parameters: lang
$service->getObjectiveNames(array('lang' => 'fr'));
$service->getItems();
Required parameters: item_id Optional parameters: lang
$service->getItemDetails(array('item_id' => 15728));
$service->getRecipes();
Required parameters: recipe_id
$service->getRecipeDetails(array('recipe_id' => 984));
Required parameters: guild_id or guild_name
$service->getGuildDetails(array('guild_name' => 'In Time'));
$service->getBuild();
Optional parameters: lang
$service->getColours(array('lang' => 'fr'));
Alias of getColours()
for our American friends.
Optional parameters: lang
$service->getColors(array('lang' => 'fr'));
Released under the MIT licence
Feedback and contribution are welcomed!