I have a URL that returns a JSON object like this:
{
"expires_in":5180976,
"access_token":"AQXzQgKTpTSjs-qiBh30aMgm3_Kb53oIf-VA733BpAogVE5jpz3jujU65WJ1XXSvVm1xr2LslGLLCWTNV5Kd_8J1YUx26axkt1E-vsOdvUAgMFH1VJwtclAXdaxRxk5UtmCWeISB6rx6NtvDt7yohnaarpBJjHWMsWYtpNn6nD87n0syud0"
}
I want to get JSON object from the URL and then the access_token
value.
So how can I retrieve it through PHP?
For this to work,
file_get_contents
requires thatallow_url_fopen
is enabled. This can be done at runtime by including:You can also use
curl
to get the url. To use curl, you can use the example found here: