AndrewFerrara Posted January 29, 2011 Share Posted January 29, 2011 Can't figure out why this is not working for me... please help! Thanks <?php $gamertag = 'l RaH l'; $url = "http://api.xboxleaders.com/user_api.php?gamertag=".rawurlencode($gamertag); $output = file_get_contents($url); // try to convert the response into a PHP object $obj = json_decode($output); if(!is_object($obj)) die("Error parsing JSON response\n"); //define variables $avatar = ($obj->user->avatar); $gold = ($obj->user->gold); print $gold; print $avatar; ?> Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/ Share on other sites More sharing options...
AndrewFerrara Posted January 29, 2011 Author Share Posted January 29, 2011 bump.. someone help please! Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/#findComment-1166921 Share on other sites More sharing options...
AndrewFerrara Posted January 29, 2011 Author Share Posted January 29, 2011 bump.. please please please help lol Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/#findComment-1166931 Share on other sites More sharing options...
l4nc3r Posted January 29, 2011 Share Posted January 29, 2011 What error are you getting? What is $output equal to? What does the print_r on the $obj look like? When you're debugging, you have to know everything about your program. You want to know what every little variable is equal to and why it's acting the way it is. Post on my blog about it here. Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/#findComment-1166977 Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2011 Share Posted January 29, 2011 Do not bump threads unless providing additional, relevant information. Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/#findComment-1167034 Share on other sites More sharing options...
AndrewFerrara Posted January 29, 2011 Author Share Posted January 29, 2011 Please somebody actual take a look at this It like to different parent Arrays i guess, no clue how to access the second one this is what the $output prints: {"error":{"code":200,"desc":"OK"}}{"user":{"gold":1,"gamertag":"l RaH l","avatar":"http:\/\/avatar.xboxlive.com\/avatar\/l%20RaH%20l\/avatarpic-l.png","gamerscore":12508,"reputation":20},"recent_games":[{"recent_game":{"title":"Halo: Reach","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1297287259&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/ih\/ew\/0Wdsb2JhbA9ECgR8GgMfVlohL2ljb24vMC84MDAwIAAAAAAAAP6fF5U=.jpg"}},{"recent_game":{"title":"Halo 3","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1297287142&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/Us\/3e\/1Wdsb2JhbA9ECgR8GgMfWSpVL2ljb24vMC84MDAwIAAAAAAAAPrxzU0=.jpg"}},{"recent_game":{"title":"AC Brotherhood","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1431504989&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/oK\/tp\/1Wdsb2JhbA9ECgUNGgMfVlonL2ljb24vMC84MDAwIAAAAAAAAPpGq78=.jpg"}},{"recent_game":{"title":"Fighters Uncaged","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1431504974&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/v+\/Au\/0Wdsb2JhbA9ECgUNGgMfVlsmL2ljb24vMC84MDAwIAAAAAAAAP4B4KA=.jpg"}},{"recent_game":{"title":"Assassin's Creed","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1431504852&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/L3\/mu\/0Wdsb2JhbA9ECgUNGgMfWStXL2ljb24vMC84MDAwIAAAAAAAAP6BeTA=.jpg"}}]} Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/#findComment-1167125 Share on other sites More sharing options...
l4nc3r Posted January 30, 2011 Share Posted January 30, 2011 I was trying to "actually help." You can't just post code, say it doesn't work, and expect to get helpful responses back. We need to know what your code is doing. If you followed the guidelines in that blog post, you could probably figure this out for yourself. That looks like fine output for $output. What does $obj print out? Quote Link to comment https://forums.phpfreaks.com/topic/226038-api-troubles/#findComment-1167377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.