PHP 5.3+ API Wrapper (examples)

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

Since I see others posting their solutions here, I thought I’d share the PHP (5.3+) wrapper I developed over the course of bank holiday Monday:

https://github.com/jamesmcfadden/PhpGw2Api

I’ve added a simple example here which I plan to improve when I have some more spare time:

http://www.gw2dashboard.net

Thanks for looking!

(edited by Nexun.6932)

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: yakobu.4183

yakobu.4183

Nice, is it possible to set the cache lifetime to different time spans depending on the data cached?

MBP 13", Early 2011, 2.7 GHz i7, 8 GB 1333 MHz DDR3, Intel HD Graphics 3000 512 MB, OS X 10.8.2

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

Nice, is it possible to set the cache lifetime to different time spans depending on the data cached?

Not currently, but that’s something I’ll certainly look into implementing next.

Thanks for the feedback!

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Zies.8142

Zies.8142

Thanks for providing this. I would have had no idea how to do all that myself.

I did spot a tiny error in Service.php.

public function getMatchDetails(array $parameters)
	{
		if(!array_key_exists('match_id', $parameters)) {
			throw new \Exception('match_id is required');
		}
		return $this->_processRequest(self::MATCH_URI, $parameters);
	}

MATCH_URI -> MATCH_DETAIL_URI

Was wondering a while why the output was looking so weird :)

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

Thanks for providing this. I would have had no idea how to do all that myself.

I did spot a tiny error in Service.php.

public function getMatchDetails(array $parameters)
	{
		if(!array_key_exists('match_id', $parameters)) {
			throw new \Exception('match_id is required');
		}
		return $this->_processRequest(self::MATCH_URI, $parameters);
	}

MATCH_URI -> MATCH_DETAIL_URI

Was wondering a while why the output was looking so weird

Hmm, not sure how that one slipped through I’ve fixed and pushed to the repository.

Thanks for your feedback!

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

I’ve update the wrapper so it’s now possible to to specify cache lifetimes on a per request basis!

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

WvW examples:
http://www.gw2dashboard.net/wvw

Still in development but wanted to push it out early

(edited by Nexun.6932)

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: MrsAngelD.6971

MrsAngelD.6971

I wish I was a coder, I have no idea how to utilize this

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

I wish I was a coder, I have no idea how to utilize this

Have you any experience with PHP at all? If not the easiest way to get an environment setup (assuming you’re on Windows) is probably with a package such as WAMP (http://www.wampserver.com/en/) or XAMPP (http://www.apachefriends.org/en/xampp.html). These packages install PHP and a local Apache server for you to serve PHP scripts via your web browser. There are loads of tutorials around the web to help, try http://www.simplehelp.net/2008/08/25/how-to-install-and-setup-apache-mysql-and-php-in-windows/

As for the API wrapper itself there is some (brief) documentation on the GitHub page.

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Rawrfaec.6412

Rawrfaec.6412

If you’re on Windows the fastest way to get started is almost surely with The Uniform Server, which doesn’t even require installation.

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

If you’re on Windows the fastest way to get started is almost surely with The Uniform Server, which doesn’t even require installation.

I’ve either never come across this, or completely forgot about it, thanks for the tip!

In other news, I’ve updated the wrapper to support the latest API changes; namely the guild_details, build and color requests.

Updates and other bug fixes are few and far between as I’m out of the country for a while.

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

I love how the API is evolving – I’ve just updated the wrapper to support the continents, maps and map_floor APIs.

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: klaufel.4178

klaufel.4178

I created this simple but very useful wordpress plugin using the SDK PhpGw2Api (https://github.com/jamesmcfadden/PhpGw2Api)

Thanks Nexum! great job!!

Guild Wars 2 – WvW Matchups (Plugin for Wordpress)

  • Plugin for WordPress, to display the live scores of WvW matchups in Guild Wars 2.

Plugin URL: http://wordpress.org/plugins/guild-wars-2-wvw-matchups/

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

I created this simple but very useful wordpress plugin using the SDK PhpGw2Api (https://github.com/jamesmcfadden/PhpGw2Api)

Thanks Nexum! great job!!

Guild Wars 2 – WvW Matchups (Plugin for Wordpress)

  • Plugin for WordPress, to display the live scores of WvW matchups in Guild Wars 2.

Plugin URL: http://wordpress.org/plugins/guild-wars-2-wvw-matchups/

I’ve just tried the plugin out on my local machine – great work, really simple to get working! I’m glad you found the wrapper useful

Just a quick note – I couldn’t download the plugin from your website (had to go directly to the Wordpress plugin site).

Thanks again!

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: thebigredone.1269

thebigredone.1269

Very nice work, since someone already did WordPress I might just do Drupal when I have the time.

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

Just thought I’d drop a note to say I’ve updated the wrapper to support the new files API

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: anzenketh.3759

anzenketh.3759

I am using the Php-Gw2-Api wrapper. It currently only works on one request. So doing the initial pull is slow. I was trying to find a way to speed it up.

I was reading:
https://forum-en.gw2archive.eu/forum/community/api/Add-item-names-Item-Recipe-responses/first#post2063524

Doing some research I found curl-multi-exec may preform the actions that I want. However I am having a hard time Modifying the code for Php-Gw2-Api to make multiple pull requests.

Looking for some help.

In Game: Storm Bluff Isle — Anzz, Anzenketh Kyoto

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

I am using the Php-Gw2-Api wrapper. It currently only works on one request. So doing the initial pull is slow. I was trying to find a way to speed it up.

I was reading:
https://forum-en.gw2archive.eu/forum/community/api/Add-item-names-Item-Recipe-responses/first#post2063524

Doing some research I found curl-multi-exec may preform the actions that I want. However I am having a hard time Modifying the code for Php-Gw2-Api to make multiple pull requests.

Looking for some help.

Sorry for the late response, I’ve been out of the country with no Internet access for the past week.

I’m going to try and get on later or tomorrow to look into adding support for this. In the meantime if anyone else wants to, feel free to submit a pull request to anzenketh’s open issue here

Thanks

PHP 5.3+ API Wrapper (examples)

in API Development

Posted by: Nexun.6932

Nexun.6932

I’ve just updated the wrapper to support HTTP pipelining:

https://github.com/jamesmcfadden/Php-Gw2-Api#parallel-requests

What this means is that you may now make multiple requests in parallel, rather than sequentially (which is much faster!). I haven’t had much time to test this update so all feedback is appreciated!

Thanks