基于php的影讯接口调用代码实例

上传人:宝路 文档编号:8350469 上传时间:2017-09-27 格式:DOC 页数:3 大小:113.50KB
返回 下载 相关 举报
基于php的影讯接口调用代码实例_第1页
第1页 / 共3页
基于php的影讯接口调用代码实例_第2页
第2页 / 共3页
基于php的影讯接口调用代码实例_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

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

1、基于 php的影讯接口调用代码实例代码描述:基于 php 的影讯接口调用代码实例代码平台:聚合数据/ +-/-/ 影视 影讯检 索调用示例代 码 聚合数据/ 在线 接口文档: http:/ 请 的 appkey$appkey = *;/*1.影视搜索*$url = http:/ = array(key = $appkey,/应用 APPKEY(应用详细页查询)dtype = ,/返回数据的格式 ,xml 或 json,默认 jsonq = ,/影视搜索名称);$paramstring = http_build_query($params);$content = juhecurl($url,$p

2、aramstring);$result = json_decode($content,true);if($result)if($resulterror_code=0)print_r($result);elseecho $resulterror_code.:.$resultreason;elseecho 请求失败;/*/*2.最近影讯*$url = http:/ = array(key = $appkey,/应用 APPKEY(应用详细页查询)dtype = ,/返回数据的格式 ,xml 或 json,默认 jsoncity = ,/城市名称);$paramstring = http_build

3、_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 请求失败;/*/* 请求接口返回内容* param string $url 请求的 URL 地址* param string $params 请求的参数 * param int $ipost 是否采用 POST

4、 形式* 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_USERAGENT , JuheData );curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );curl_setopt( $ch, CURLOPT_TIMEOUT

5、 , 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 , $params );curl_setopt( $ch , CURLOPT_URL , $url );elseif($params)curl_setopt( $ch , CURLOPT_URL , $url

6、.?.$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号