<?php
//curl请求k780接口header("Content-Type:text/html;charset=UTF-8");$url='http://api.k780.com:88/?app=weather.future&weaid=1&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json';$ch = curl_init();//初始化curlcurl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页curl_setopt($ch, CURLOPT_HEADER, 0);//设置headercurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上curl_setopt($ch, CURLOPT_POST, 1); //post提交方式// curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost)$data = curl_exec($ch);//运行curlcurl_close($ch);print_r($data);die;//php请求k780接口function nowapi_call($a_parm){ if(!is_array($a_parm)){ return false; } //combinations $a_parm['format']=empty($a_parm['format'])?'json':$a_parm['format']; $apiurl=empty($a_parm['apiurl'])?'http://api.k780.com:88/?':$a_parm['apiurl'].'/?'; unset($a_parm['apiurl']); foreach($a_parm as $k=>$v){ $apiurl.=$k.'='.$v.'&'; } $apiurl=substr($apiurl,0,-1); if(!$callapi=file_get_contents($apiurl)){ return false; } //format if($a_parm['format']=='base64'){ $a_cdata=unserialize(base64_decode($callapi)); }elseif($a_parm['format']=='json'){ if(!$a_cdata=json_decode($callapi,true)){ return false; } }else{ return false; } //array if($a_cdata['success']!='1'){ echo $a_cdata['msgid'].' '.$a_cdata['msg']; return false; } return $a_cdata['result'];}$nowapi_parm['app']='weather.future';$nowapi_parm['weaid']='1';$nowapi_parm['appkey']='22084';$nowapi_parm['sign']='24a673cd5d57baad69e5e61fa21849f7';$nowapi_parm['format']='json';$result=nowapi_call($nowapi_parm);var_dump($result);print_r($result);