Rogue Modder Posted January 23, 2011 Report Posted January 23, 2011 the Reach API returns a object for emblum, but i want a string (url string). How do i convert the object into a string. (lack of debugging in PHP gets on my tits). Alex.
iBotPeaches Posted January 23, 2011 Report Posted January 23, 2011 Pass $information['Player']['ReachEmblem'] from /player/details/nostats API, to this neat function, which I ended up posting on haloreachapi.net. Then you get returned a string of the URL. You can specify the size, but otherwise its defaulted to 70. private function _getEmblem($subject, $size = 70) { /* check for array */ if (is_array($subject)) { /* thanks: http://www.haloreachapi.net/wiki/Emblems */ /* Emblem to Link */ $bi = $subject['background_index']; $fi = $subject['foreground_index']; $fl = $subject['flags'] ? 0 : 1; $c0 = $subject['change_colors'][0]; $c1 = $subject['change_colors'][1]; $c2 = $subject['change_colors'][2]; $c3 = $subject['change_colors'][3]; /* Send it back */ return "http://www.bungie.net/Stats/emblem.ashx?s=$size&0=$c0&1=$c1&2=$c2&3=$c3&fi=$fi&bi=$bi&fl=$fl&m=3"; } else { return ""; } } 2
Rogue Modder Posted January 23, 2011 Author Report Posted January 23, 2011 (edited) Ahh, i saw that on the API wiki, but im very new to PHP. so i had no idea what todo with it. Thanks Update:I'm getthig this error;"Fatal error: Cannot use object of type stdClass as array in ***/reachstats.php on line 49" How are you calling the function? Edited January 23, 2011 by Xerax
iBotPeaches Posted January 23, 2011 Report Posted January 23, 2011 O your using it as objects instead of arrays. Find where you read the json, and append true into the parameters. Boom done. 1
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now