Reputation: 9
This is the part who does errors:
$inv = 'http://steamapi.csgodirect.com/getInventory?steamid=76561198076372985';
@$inv = file_get_contents($inv);
$inv = json_decode($inv, true);
if($inv['success'] != 1) {
$privateinventory = 1;
}
else{
$privateinventory = 0;
}
echo $privateinventory;
I always get 1, but it should be 0. JSON - Code is avaiable on the Site but for some reason he says it was not successfull.
Upvotes: 0
Views: 173
Reputation: 182
There is no success key in given json file but if you need to check you can check if json is valid or not with json_decode($inv) != null , for now from your question i thought this may help you.
error_reporting(E_ALL);
$inv = 'http://steamapi.csgodirect.com/getInventory?steamid=76561198076372985';
@$inv = file_get_contents($inv);
//var_dump($inv);
//var_dump(json_decode($inv, true));
if (json_decode($inv) != null) {
$privateinventory = 0;
} else {
$privateinventory = 1;
}
echo $privateinventory;
If this will not match your requirements then try to describe more.
Upvotes: 1