I want to get the yahoo woeid by php script.
I can access the url 'http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text="NewYork"&format=json' and get the json file in my browser.But when I use the curl it return null.
that's the code.
public function getwoeid(){
$ch = curl_init();
$url = 'http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text="'.$this->cityname.'"&format=json';
//echo $url;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data=curl_exec($ch) or die($this->returnerror());
curl_close($ch);
$array = json_decode($data, true);
return $array;
}
when I try to access the 'http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text="上海"&format=json' the curl works fine.
I can't fix it.
any suggestion would be appreciated! Thanks.