When I run the code below, I get the error:
file_get_contents(http://roblox.plus:2052/limiteds): failed to open stream: Connection refused
$file = file_get_contents('http://roblox.plus:2052/limiteds');
$decode = json_decode($file, false);
foreach($decode AS $person) {
echo $person->name . ": " . $person->lowestPrice . "<br><br>";
}
Why is this? I can access the website fine through my browser. I also tried the code on PHP Fiddle.
Following the comments, I have attempted to use cURL
- no results are displayed though.
$url = 'http://roblox.plus:2052/limiteds';
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
// Decode
$decode = json_decode($result, false);
foreach($decode AS $person) {
echo $person->name . ": " . $person->lowestPrice . "<br><br>";
}