I am having issues with this code
This is my PHP that worked with other projects…
$gas = file_get_contents('http://api.mygasfeed.com/stations/loadbygeo/47.9494949/120.23423432/reg|mid|pre|diesel/'. $api . '.json?callback=?');
$json_output = json_decode(utf8_decode($gas));
$location= $json_output->geoLocation->city_id;
This is the JSON result
?({"status":{"error":"NO","code":200,"description":"none","message":"Request ok"},"geoLocation":{"city_id":"13123","city_long":"Hulunber","region_short":"Nei Mongol","region_long":"Nei Mongol","country_long":"China","country_id":"49","region_id":"6010"},"stations":[]})
This code is returning a blank result.
You need to remove the
?(and the). See WP:JSONP.One could use
substr()for that, or better yet a regex to assert and remove only the desired garbage:Would remove arbitrary
callbackFnNames(but also your strange?(pseudo function call.