php - What to do with a JSON Object Response? -


i working google oauth 2 , able access token. google returned access token in json object. output printed out on browser. since i've never touched json or other api before, have no idea how capture json object can store access token.

example output(obscured actual data)

{ "access_token":"1/6gkfqror6000000004k10qgr000000giuirnblnc", "token_type":"bearer", "expires_in":3600, "refresh_token": "1/vx34lfpisdux000000kq_sjwigf42fvs" } 

i tried simple $token = $_post['access_token']; didn't work. json_decode didn't work. i'm pretty sure i'm not doing right here. can tell me how can interact json object?

edit:

i guess initial question more rudimentary because i'm new @ api programming. want know how encapsulate browser response of json object variable php script can dynamically decode response. currently, browser replied content of json object posted above don't know object name or variable name $object = {}. there way find out object name or way put response object or array dynamically?

{ "access_token":"1/6gkfqror6000000004k10qgr000000giuirnblnc", "token_type":"bearer", "expires_in":3600, "refresh_token": "1/vx34lfpisdux000000kq_sjwigf42fvs" } 

put complete response in json object : jsonobject jobject = new jsonobject(response);

now access token: string value= jobject.getstring("access_token"); http://developer.android.com/reference/org/json/jsonobject.html

http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -