Any working PHP Library with the new API?

API Discussion
I'm looking for a php library that works with the new changes to the API. Anyone know one?
There's two different examples in this thread:

https://us.battle.net/forums/en/bnet/topic/20769657132

Good luck.
I recommend using a Library like http://docs.guzzlephp.org/en/stable and https://github.com/kamermans/guzzle-oauth2-subscriber both found in GitHub instead of implementing your own script using curl, for security reasons.

And example on how to query the wow api with both Library would be like this:
https://gist.github.com/bnmosria/66400b2634c43bfbbdd2947634f9b0bf

You can read the documentations of both Libraries on how to configure the headers and query for better performance and caching.

function auth_token()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://us.battle.net/oauth/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, WOW_API_CLIENT_ID.":".WOW_API_CLIENT_PW);
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
//echo 'Error:' . curl_error($ch);
return false;
}
curl_close($ch);
$data = json_decode($result, true);
return $data["access_token"];
}


[code][/code]

Join the Conversation

Return to Forum