so i have neerly finished my php-api and thought id help some people out
this is a function i use to get a well formed url for my script rather then having to code a url all the time i pass bits of data and get a full return
/*
@ui the battle.net region url
@class is the type of data being asked for character,status,team ...
@server wow realm name (url functions removes ' and replaces + with %20 as per blizzard url settings)
@name ither character team or guild names
@fields this is optional data you wana pass along to the url fields or multiple realm names
!q returnd fuly formed url for the api
*/
function BuildUrl($ui,$class,$server,$name,$fields)
{
$name = str_replace('+' , '%20' , urlencode($name));
$server = strtolower(str_replace("\'" , '' ,$server));
$server = str_replace('+' , '%20' , urlencode($server));
switch ($class)
{
case 'character':
// /api/wow/character/{realm}/{name}
$q = 'api/wow/character/'.$server.'/'.$name.$fields['data'].'';
break;
case 'status':
$q = 'api/wow/realm/status?'.$fields['data'].'';
break;
case 'guild':
// /api/wow/guild/{realm}/{name}
$q = 'api/wow/guild/'.$server.'/'.$name.'/'.$fields['data'].'';
break;
case 'team':
// /api/wow/arena/{realm}/{size}/{name} (size being 2v2, 3v3 or 5v5)
$q = 'api/wow/arena/'.$server.'/'.$field['data'].'/'.$name.'';
break;
case 'item':
#api/wow/data/item/38268
$q = 'api/wow/item/'.$name;
break;
case 'gperks':
$q = 'api/wow/data/guild/perks';
break;
case 'gachievments':
$q = 'api/wow/data/guild/perks';
break;
case 'grewards':
$q = 'api/wow/data/guild/rewards';
break;
case 'races':
$q = 'api/wow/data/character/races';
break;
case 'achievement':
$q = 'api/wow/data/achievement/'.$name.'';
break;
default:
$q = '';
break;
}
return $q;
}
Ial continue to post more code to help anyone out