Jump to content

json_decode wont accept variable


Rsmiley

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/265653-json_decode-wont-accept-variable/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.