Rsmiley Posted July 14, 2012 Share Posted July 14, 2012 So its my first time dealing with json_decode and I'm finding it rather difficult. It only accepts and decodes the info when its in plain text attached to a variable but refuses to do it from a variable from a query Heres the code $params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI); $response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params); //parse_str($response['result'], $infob); print '<br /><b>pretty_var($response)</b><br />$response = $client->getAccessToken<br />'; pretty_var($response); ##DOESN'T -> $trying = $response['result']; ##WORKS-> //$trying = '{"error":1,"error_message":"[OAuth error: invalid_request] The authorization code is invalid.","access_token":null}'; $appear = json_decode($trying); print "This is supposed to be,".$appear->{'error_message'}; print '<br /><br /><br /><b>pretty_var($response, $response[\'result\'])</b><br />$response = $client->fetch<br />'; //$fuck = {"error":1,"error_message":"[OAuth error: invalid_request] The authorization code is invalid.","access_token":null}'; //mysql_query("insert into `oauth` (`id`,`ip`,`key`) VALUES('','{$ip}','{$info['access_token']}')") or die('wtf dude: '.mysql_error()); //$client->setAccessToken('fc09147a2b11a9e9d1a0999b356d12e431d19f1f'); $client->setAccessToken($info['access_token']); $response = $client->fetch('http://api.subeta.net/user/user_details'); pretty_var($response, $response['result']); pretty_var($response) $response = $client->getAccessToken array ( 'result' => '{"error":1,"error_message":"[OAuth error: invalid_request] The authorization code is invalid.","access_token":null}', 'code' => 403, 'content_type' => 'text/html', ) I've tried everything I can think of to make it accept it but it refuses, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/265653-json_decode-wont-accept-variable/ Share on other sites More sharing options...
scootstah Posted July 14, 2012 Share Posted July 14, 2012 View the page source, are the quotes encoded? Quote Link to comment https://forums.phpfreaks.com/topic/265653-json_decode-wont-accept-variable/#findComment-1361453 Share on other sites More sharing options...
Rsmiley Posted July 14, 2012 Author Share Posted July 14, 2012 Thanks to you telling me to view the source, I found the problem. The server sending the result was including a ton of 'magic JS' with the result causing it to not decode (obviously) Hopefully they will have it fixed soon, they said it would be earlier but who knows with them. Thank you! If something else comes up I'll be sure to ask again Quote Link to comment https://forums.phpfreaks.com/topic/265653-json_decode-wont-accept-variable/#findComment-1361531 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.