예제 #1
0
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
            //post参数
        }
        if ($this->_setProxy) {
            curl_setopt($ch, CURLOPT_PROXY, $this->_proxy);
            //公司环境,设置代理
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        //将curl_exec()获取的信息以文件流的形式返回,而不是直接输出
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        //设置超时时间(单位:秒)
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        //不验证证书下同
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        //
        $result = curl_exec($ch);
        //执行会话
        if (curl_errno($ch)) {
            //获取错误信息
            //            $info = curl_getinfo($ch);
        }
        curl_close($ch);
        return $result;
    }
}
set_time_limit(0);
$weather = new Weather('fa31b4_SmartWeatherAPI_504c86f', '35b756e2e8acc9ab', true);
$weather->getWeatherReport('101021300');
$weather->getWeatherPoint('101021300');