$json = file_get_contents('url_here');
$obj = json_decode($json);
echo $obj->access_token;

For this to work, file_get_contents requires that allow_url_fopen is enabled. This can be done at runtime by including:

ini_set("allow_url_fopen", 1);

You can also use curl to get the URL. To use curl, you can use the example found here:

$ch = curl_init();
// IMPORTANT: the below line is a security risk, read https://paragonie.com/blog/2017/10/certainty-automated-cacert-pem-management-for-php-software
// in most cases, you should set it to true
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'url_here');
$result = curl_exec($ch);
curl_close(obj = json_decode($result);
echo $obj->access_token;
Answer from Prisoner on Stack Overflow
🌐
ReqBin
reqbin.com › req › php › 5nqtoxbx › get-json-example
PHP | How to get JSON from URL?
To request JSON from an URL using PHP, you need to send an HTTP GET request to the server and provide the Accept: application/json request header with your request. The Accept header tells the server that our PHP client is expecting JSON.
🌐
Koding Made Simple
kodingmadesimple.com › 2016 › 02 › get-json-from-url-in-php.html
Get JSON from URL in PHP
The php function file_get_contents($url) send a http request to the provided url and returns json data. The function json_decode($json) decodes the provided json string and returns as a PHP object.
🌐
W3Schools
w3schools.com › js › js_json_php.asp
JSON PHP
On the client, make a JSON object that describes the numbers of rows you want to return. Before you send the request to the server, convert the JSON object into a string and send it as a parameter to the url of the PHP ...
🌐
Delft Stack
delftstack.com › home › howto › php › php get json from url
How to Get JSON Object From URL in PHP | Delft Stack
February 2, 2024 - Use the curl_close() function to close the $curl variable. Next, use the json_decode() function to change the JSON object to PHP object and display the title object. Thus, we can get the JSON object from a URL using curl.
🌐
Edureka Community
edureka.co › home › community › categories › blockchain › extract data from json url result php
Extract data from Json url result php | Edureka Community
September 3, 2018 - I am trying to run a url for getting balance of a address. Which gives the JSON: { "balance": ... > But it returns nothing. What am I doing wrong?
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-pass-json-data-in-a-url-using-curl-in-php
How to Pass JSON Data in a URL using CURL in PHP ? - GeeksforGeeks
July 23, 2025 - Put JSON data in a PHP array and set up JSON data. And using json_encode() encode it into JSON string. Setting the options for the cURL. Fetching $url using CURLOPT_URL. Switching request type from get to post using CURLOPT_POST.
Find elsewhere
🌐
Tania's Website
taniarascia.com › how to request json api data with javascript or php
How to Request JSON API Data with JavaScript or PHP | Tania Rascia's Website
$url = 'data.json'; // path to your JSON file $data = file_get_contents($url); // put the contents of the file into a variable $characters = json_decode($data); // decode the JSON feed
🌐
Kirby Forum
forum.getkirby.com › the cms › questions
Get JSON data from external website and parse it to show in HTML - Questions - Kirby Forum
March 6, 2018 - Is there a simple example how to fetch JSON data from an external website (like for example http://openweathermap.org/current ) and parse one of the values (e.g. ‘temp’) so it would show up in my HTML? All i found so fa…
🌐
ReqBin
reqbin.com › req › php › ewk2va7p › get-request-to-retrieve-a-json
PHP | How do I send a get JSON request?
To get JSON from the server using PHP, you must send an HTTP GET request and pass the "Accept: application/json" HTTP header, which will tell the server that the client expects JSON in response.
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-parse-a-json-file-in-php
How to parse a JSON File in PHP? - GeeksforGeeks
Parsing JSON data in PHP is simple and efficient. With the use of functions like file_get_contents() and json_decode(), you can easily load and process JSON data in your PHP applications.
Published   June 24, 2025
🌐
Quora
quora.com › What-is-the-best-way-to-fetch-and-parse-JSON-data-using-PHP
What is the best way to fetch and parse JSON data using PHP? - Quora
Answer: It depends on what extensions or frameworks you have available to you, if you just doing it raw without cURL extension then you need to open the JSON content read it into a buffer close the socket connection then json_parse the JSON, if ...
🌐
PHPpot
phppot.com › php › json-post-php
Receive JSON POST in PHP - PHPpot
This function reads the raw JSON data from the request body. It uses the PHP file_get_contents(‘php://input’) and json_encode() to get the JSON string posted.
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-return-json-from-a-php-script
How to Return JSON from a PHP Script ? - GeeksforGeeks
July 23, 2025 - <?php $jsonData = array( 'organization' ... json_encode($jsonData); ?> ... In this approach, we are using file_get_contents() to fetch JSON data from the specified URL ($jsonPlaceholderUrl), which in this case is the JSONPlaceholder ...
🌐
YouTube
youtube.com › watch
jQuery GET JSON from URL Tutorial: Retrieve data from a PHP script - YouTube
In this tutorial you will learn how to use jQuery to GET JSON from a URL. Recommended training (Free for 7 days) : https://juniordevelopercentral.com/treeho...
Published   September 24, 2018