Mitchell Welch Mitchell Welch - 1 month ago 4x
PHP Question

file_get_contents failed to open stream : invalid argument with URL

I am trying to get details for bans on a Steam user account using the file_get_contents function in PHP. However, it keeps erroring and I have no idea why:

$detailURL = file_get_contents("");
$profile = file_get_contents($detailURL);
$buffer = fopen("coOn4LxnQm/{$steamIDpost}.json", "w+");
fwrite($buffer, $profile);

$steam = json_decode(file_get_contents("coOn4LxnQm/{$steamIDpost}.json"));

The error is as follows:

Warning: file_get_contents({ "players": [ { "SteamId": "76561198078737264", "CommunityBanned": false, "VACBanned": true, "NumberOfVACBans": 1, "DaysSinceLastBan": 309, "NumberOfGameBans": 0, "EconomyBan": "none" } ] }): failed to open stream: Invalid argument in C:\xampp\htdocs\addToList.php on line 18

If you have any idea, please help me. No idea what "failed to open stream: Invalid argument" means and googling and such did not help much.



After this line

$detailURL = file_get_contents("");

$detailURL will now contain the result from the API (a JSON String)

If you have a look at this line:

$profile = file_get_contents($detailURL);

This line is doing a file_get_contents on a JSON String, and it has no sense.