I am attempting to parse the JSON from the URL bellow. However when I run the var_dump(json_decode($result, true))
it returns NULL. But when I copy the URL from the echo $item_url
it returns the proper JSON.
Another issue I have read is the var_dump(json_decode($result, true));
is returning a string with spaces and that could be an issue
$item_url = "http://steamcommunity.com/market/priceoverview/?country=US¤cy=1&appid=730&market_hash_name=" . $rgDescriptions->market_hash_name;
echo $item_url;
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, urlencode($item_url));
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$result = curl_exec($curl_handle);
curl_close($curl_handle);
var_dump(json_decode($result, true));
Bellow is an example of a URL that may get passed.