程序:PHP(Thinkphp)
请求网址(url):http://api.k780.com:88/?app=weather.today&weaid=101290101&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json
解决方案:
由php程序发送请求并获取返回值,ajax再来调用这个php地址
PHP程序中这样写
public function get_time_weather(){
$url = 'http://api.k780.com:88/?app=weather.today&weaid=101290101&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json';
$data = file_get_contents($url);
echo $data;
}
javascrip程序中这样写
function get_time_weather(){
var url = '__URL__/get_time_weather';
$.getJSON(url, function(data){
parse_weather(data);
});
}
这样就能够取到需要的信息了。
推断原因:一般程序发送的请求,都是模拟浏览器的行为,所以对方服务器认可请求。