sixli sixli - 4 months ago 12x
PHP Question

CURL with port and additional parameters in URL, JSON parsing

I have a URL in the form of

On that URL is a JSON dump which I need to parse. How do I access it? I've used
before which is why I am struggling with this - first occasion to have a port on the URL. It would be best if I could grab the JSON and put it in a file.txt and then parse the file.

$cURL = curl_init('');
curl_setopt($cURL, CURLOPT_PORT, 10001);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);

$fp = fopen("example_homepage.txt", "w");
curl_setopt($cURL, CURLOPT_FILE, $fp);
curl_setopt($cURL, CURLOPT_HEADER, 0);

I'm not sure how to properly add the remainder of the URL.


If you don't need to use curl, it may be easier with file_get_contents.

// Retrieve file
$data = file_get_contents("");

// Echo retrieved file
echo $data;

// Decode JSON
$decoded = json_decode($data);

// Dump decoded data