I have decoded a JSON object using url, for example:
$var = json_decode(file_get_contents($url), true);
The data I receive is the new battle API, which is returned as a JSON object containing character data.
- Here is the actual link in which the symbol is found, and there is data that should be generated: Character found .
- Now here is the link for the character that does not exist and is generated, and the error: The character was not found .
Errors are returned as JSON objects that contain the status and reason attributes. The value of the status attribute will always be nok.
My problem is that the character is NOT FOUND, the JSON $ var object is NULL, where if it is FOUND, the JSON $ var object contains the correct data. I need to check if the status is "nok", so I can display the corresponding error message
I have:
- Check the links to make sure they are generated correctly.
- Changed
json_decode(file_get_contents($url), true)to: json_decode(file_get_contents($url), false)and tried to access $ var as an object. - Tried to use cURL instead
file_get_contents($url)
I posted the Battle.net APIs on the forums, but I thought I would try it too.
source
share