Meeting the requirements set for in the Battle.net Third Party API Usage Policy (http://us.battle.net/wow/en/forum/topic/3746635131M), here is the code of my site that engages the API:
/* PHP5:
*
* Function: getBnetJson($url)
* This function is very simple: it uses CURL to retrieve the JSON response from the battle.net api
* prereq: url contains a valid url
* Example URL:
* $url="http://us.battle.net/api/wow/guild/$realm/$guild?fields=members";
*/
function getBnetJson($url){
if ($url !=""){
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$content = curl_exec($ch);
curl_close($ch);
return $content;
} else {
return "CURL failed";
}
else
{
return "";
}
}