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.
iBotModz CBox
PHP Object problem
Started by Rogue Modder, Jan 22 2011 06:31 PM
3 replies to this topic
#1
Posted 22 January 2011 - 06:31 PM
#2
Posted 22 January 2011 - 06:50 PM
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.
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 ""; } }
- Rogue Modder and like this
#3
Posted 22 January 2011 - 06:55 PM
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?
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 by Xerax, 22 January 2011 - 07:14 PM.
#4
Posted 22 January 2011 - 07:39 PM
O your using it as objects instead of arrays.
Find where you read the json, and append true into the parameters. Boom done.
Find where you read the json, and append true into the parameters. Boom done.
- Rogue Modder likes this