基于php的万年历接口调用代码实例

上传人:子 文档编号:42768129 上传时间:2018-06-03 格式:DOC 页数:4 大小:134KB
返回 下载 相关 举报
基于php的万年历接口调用代码实例_第1页
第1页 / 共4页
基于php的万年历接口调用代码实例_第2页
第2页 / 共4页
基于php的万年历接口调用代码实例_第3页
第3页 / 共4页
基于php的万年历接口调用代码实例_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《基于php的万年历接口调用代码实例》由会员分享,可在线阅读,更多相关《基于php的万年历接口调用代码实例(4页珍藏版)》请在金锄头文库上搜索。

1、基于 php 的万年历接口调用代码实例代码描述:基于 php 的万年历接口调用代码实例代码平台:聚合数据/ +- -/- / 万年历调用示例代码 聚合数据 / 在线接口文档:http:/ appkey$appkey = “*“;/*1.获取当天的详细信息*$url = “http:/ $params = array(“key“ = $appkey,/您申请的 appKey“date“ = “,/指定日期,格式为 YYYY-MM-DD,如月份和日期小于 10,则取个位,如:2012-1-1 );$paramstring = http_build_query($params); $content

2、= juhecurl($url,$paramstring); $result = json_decode($content,true); if($result)if($resulterror_code=0)print_r($result);elseecho $resulterror_code.“:“.$resultreason; elseecho “请求失败“; /*/*2.获取当月近期假期*$url = “http:/ $params = array(“key“ = $appkey,/您申请的 appKey“year-month“ = “,/指定月份,格式为 YYYY-MM,如月份和日期小于

3、 10,则取个位,如:2012-1 ); $paramstring = http_build_query($params); $content = juhecurl($url,$paramstring); $result = json_decode($content,true); if($result)if($resulterror_code=0)print_r($result);elseecho $resulterror_code.“:“.$resultreason; elseecho “请求失败“; /*/*3.获取当年的假期列表*$url = “http:/ $params = arra

4、y(“key“ = $appkey,/您申请的 appKey“year“ = “,/指定年份,格式为 YYYY,如:2015); $paramstring = http_build_query($params); $content = juhecurl($url,$paramstring); $result = json_decode($content,true); if($result)if($resulterror_code=0)print_r($result);elseecho $resulterror_code.“:“.$resultreason; elseecho “请求失败“; /

5、*/* 请求接口返回内容* param string $url 请求的 URL 地址* param string $params 请求的参数* param int $ipost 是否采用 POST 形式* return string*/ function juhecurl($url,$params=false,$ispost=0)$httpInfo = array();$ch = curl_init();curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );curl_setopt( $ch, CURLOPT_USERA

6、GENT , JuheData );curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );curl_setopt( $ch, CURLOPT_TIMEOUT , 60);curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);if( $ispost )curl_setopt( $ch , CURLOPT_POST , true );curl_setopt( $ch , CURLOPT_POSTFIELDS , $pa

7、rams );curl_setopt( $ch , CURLOPT_URL , $url );elseif($params)curl_setopt( $ch , CURLOPT_URL , $url.?.$params );elsecurl_setopt( $ch , CURLOPT_URL , $url);$response = curl_exec( $ch );if ($response = FALSE) /echo “cURL Error: “ . curl_error($ch);return false;$httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );$httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );curl_close( $ch );return $response;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号