Rumah  >  Artikel  >  php教程  >  视频网站56网的SDK

视频网站56网的SDK

PHP中文网
PHP中文网asal
2016-05-25 17:11:121240semak imbas

视频网站56网的SDK

1. [图片] 视频网站56网的SDK    

视频网站56网的SDK


2. [文件]     SDK.php

<?php
/**
 * @description PHP SDK for 56 网  v2.0 (include using OAuth2),support by 56 open platform team
 * @
 * /

/**
 * @description 设定时区.
 */
define(&#39;API_TIMEZONE_OFFSET&#39;,8);
if(function_exists(&#39;date_default_timezone_set&#39;)) {
	@date_default_timezone_set(&#39;Etc/GMT&#39;.(API_TIMEZONE_OFFSET > 0 ? &#39;-&#39; : &#39;+&#39;).(abs(API_TIMEZONE_OFFSET)));
} else {
	putenv(&#39;Etc/GMT&#39;.(API_TIMEZONE_OFFSET > 0 ? &#39;-&#39; : &#39;+&#39;).(abs(API_TIMEZONE_OFFSET)));
}

/**
 * @description 常用配置.
 */	   	
error_reporting(E_ALL);
define(&#39;APPKEY&#39;,&#39;1000000010&#39;);
define(&#39;APPSECRET&#39;,&#39;0e4f13954bc537ec&#39;);
/**
 * @description 在oauth认证中请求的token
 */
define(&#39;ACCESS_TOKEN&#39;,&#39;&#39;);
define(&#39;CONNECT_TIMEOUT&#39;, 5);
define(&#39;READ_TIMEOUT&#39;, 5);

/**
 * @description 56网的接口类
 * 
 * @package open56Client
 */
class open56Client extends Exception{

	/**
	* 应用appkey
	*/
	public $appkey; 
	/**
	* 应用secret  
	*/
	public $secret;
	/**
	* 接口访问host
	*/
	public $domain = "http://oapi.56.com";
	/**
	* 用户授权access_token
	*/
	public $access_token;
	/**
	* 是否调试HTTP
	*/
	public $isDebugHttp = false;


	public function __construct($appkey,$secret){
		if(empty($appkey) || empty($secret)){
			try {
				throw new Exception("appkey or secret cannot be empty!");
			} catch(Exception $e) {
				echo $e->getMessage();
			}
		}
		$this->appkey = $appkey;
		$this->secret = $secret;
	}

	/**
	* @description 设置access_token,提供需要oauth授权才能访问的接口设置用户access_token,该值参与客户端签名。
	* 
	* @access public
	* @param mixed $token
	* @return void
	*/
	public function _setToken($token){
		if(!empty($token)){
			$this->access_token = $token;
		}	
		return $this;
	}

	/**
	* @description 简易上传组件地址
	* 
	* return void
	*/
	public function uploadUrl(){
		$url    = $this->domain."/video/upload.plugin";
		$params = array();
		return $url.&#39;?&#39;.self::signRequest($params);
	}

	/**
	* 复杂上传组件地址
	* 
	* @param $sid 第三方的应用的用户名
	* @param $css 获取的样式加密码
	* @param $rurl 失败时跳转的页面,获取返回信息
	* @param $ourl 成功时跳转的页面,获取返回信息
	*/
	public function customUrl($sid, $css, $rurl, $ourl){
		$url    = $this->domain."/video/custom.plugin";
		$params = array(&#39;sid&#39;=> $sid,&#39;css&#39;=> $css ,&#39;rurl&#39;=> $rurl,&#39;ourl&#39;=> $ourl);
		return $url.&#39;?&#39;.self::signRequest($params);
	}

	/**
	* @description 获取视频信息
	* 
	* @param $flvid 56视频的flvid
	* @link /video/getVideoInfo.json
	* @return json
	*/
	public function  getVideoInfoApp($flvid){
		$url    = $this->domain.&#39;/video/getVideoInfo.json&#39;;
		$params = array(&#39;vid&#39;=>$flvid);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获取更新视频信息的接口
	* 
	* @param $flvid 56视频的flvid
	* @param $title 56视频的名称
	* @param $desc  56视频的名称的描述
	* @param $tag   56视频的标签
	* @link  /video/update.json
	* @return json
	*/
	public function  updateApp($flvid,$title,$desc,$tag){
		$url    = $this->domain.&#39;/video/update.json&#39;;
		$params = array(&#39;vid&#39;=>$flvid,&#39;title&#39;=>$title,&#39;desc&#39;=>$desc,&#39;tag&#39;=>$tag);
		return self::getHttp($url,$params);
	}

	/*
	* @description 根据关键字获取搜索结果
	*   $data = array(
	*       &#39;keyword&#39;=> $keyword,  //要查找的关键字
	*       &#39;c&#39;=>1,
	*       &#39;t&#39;=>&#39;month&#39;, 时间,默认为month
	*       &#39;s&#39;=>1,
	*       &#39;page&#39;=>1,     当前页数
	*       &#39;rows&#39;=>$rows, 10 每页显示多少个
	*    );  
	* @param $keyword 主要的字段,关键字搜索,其他的默认即可
	* @link  /video/search.json
	* @return json
	*/
	public function  searchVideo($data){
		$url    = $this->domain.&#39;/video/search.json&#39;;
		$params = array();
		$params = array_merge($params,$data);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获取用户的个人信息
	* 
	* @param $userid 用户在56网站的user_id或视频的flvid
	* @param $token oauth2认证后的令牌
	* @link  /user/userProfile.json
	* @return json
	*/
	public function userInfo($userid){
		$url	= $this->domain.&#39;/user/userProfile.json&#39;;
		$params	= array(&#39;userid&#39;=>$userid,&#39;access_token&#39;=>$token);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获取用户的上传的视频
	* 
	* @param $userid 用户在56网站的user_id或视频的flvid
	* @param $token oauth2认证后的令牌
	* @link  /user/userVideos.json 
	* @return json
	*/
	public function userVideos($userid){
		$url    = $this->domain.&#39;/user/userVideos.json&#39;;
		$params = array(&#39;userid&#39;=>$userid,&#39;access_token&#39;=>$token,&#39;s&#39;=>&#39;time&#39;,&#39;page&#39;=>1,&#39;rows&#39;=>10);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得用户的评论或视频的评论
	* 
	* @param $tid 用户在56网站的user_id或视频的flvid
	* @param $type user/flv
	* @param $token oauth2认证后的令牌
	* @param $pct  1为普通视频 3是相册视频
	* @return json
	*/
	public function userComments($tid = &#39;onesec&#39;, $type = &#39;user&#39;, $pct = 1){
		$url    = $this->domain.&#39;/user/userComments.json&#39;;
		$params = array(&#39;tid&#39;=>$tid,&#39;access_token&#39;=>$token,&#39;type&#39;=> $type,&#39;page&#39;=>1,&#39;rows&#39;=>10, &#39;pct&#39;=> $pct);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得频道的视频
	* 
	* @access public
	* @param string $cid
	* @param string $page
	* @param string $num
	* @return json
	*/
	public function channelVideo($cid = &#39;68&#39;, $page = &#39;1&#39;, $num = &#39;20&#39;){
		$url    = $this->domain.&#39;/video/channel.json&#39;;
		$params = array(&#39;cid&#39;=>$cid, &#39;page&#39;=>$page, &#39;num&#39;=>$num);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得推荐频道的视频
	* 
	* @access public
	* @param string $mid
	* @param string $page
	* @param string $num
	* @return json
	*/
	public function recommendVideo($mid = &#39;16&#39;, $page = &#39;1&#39;, $num = &#39;10&#39;){
		$url    = $this->domain.&#39;/video/recommend.json&#39;;
		$params = array(&#39;mid&#39;=>$mid, &#39;page&#39;=>$page, &#39;num&#39;=>$num);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得56网首页热门的视频
	* 
	* @access public
	* @param string $cid
	* @param string $page
	* @param string $num
	* @return json
	*/
	public function hotVideo($cid = &#39;2&#39;, $page = &#39;1&#39;, $num = &#39;10&#39;){
		$url    = $this->domain.&#39;/video/hot.json&#39;;
		$params = array(&#39;cid&#39;=>$cid, &#39;page&#39;=>$page, &#39;num&#39;=>$num);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得56网昨天或某天的推荐的相册视频
	* 
	* @access public
	* @param mixed $day
	* @return json|void
	*/
	public function albumVideo($day){
		$url    = $this->domain.&#39;/video/recAlbum.json&#39;;
		$params = array(&#39;day&#39;=>$day);
		return self::getHttp($url,$params);
	}

	/**
	* @description GET 方法
	* 
	* @access private
	* @param mixed $url
	* @param array $params
	* @return json
	*/
	public  function getHttp($url,$params=array()){
		$url = $url.&#39;?&#39;.self::signRequest($params);
		return self::httpCall($url);
	}

	/**
	* @description  POST 方法
	* 
	* @access private
	* @param mixed $url
	* @param mixed $params
	* @return json
	*/
	public  function postHttp($url,$params){
		return self::httpCall($url,self::signRequest($params),&#39;post&#39;);
	}

	/**
	* @description  curl method,post方法params字符串的位置不同于get
	* 
	* @access public
	* @param mixed $url
	* @param string $params
	* @param string $method
	* @param mixed $connectTimeout
	* @param mixed $readTimeout
	* @return json
	*/
	public function httpCall($url ,$params = &#39;&#39;,$method = &#39;get&#39;, $connectTimeout = CONNECT_TIMEOUT, $readTimeout = READ_TIMEOUT) {

		$result = "";
		if (function_exists(&#39;curl_init&#39;)) {
			$timeout = $connectTimeout + $readTimeout;
			/** Use CURL if installed...  **/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $url);
			if (strtolower($method)===&#39;post&#39;){ 
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
			}
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout);
			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_USERAGENT, &#39;56.com API PHP5 Client 1.1 (curl) &#39; . phpversion());
			$result = curl_exec($ch);
		} else{
			if (isset($params) and $params){
				$url = $url."?".http_build_query($params);
			}
		    /** Non-CURL based version... */
			$ctx = stream_context_create(
				array(  
					&#39;http&#39; => array(  
						&#39;timeout&#39; => 5 /** 设置一个超时时间,单位为秒 */
					)  
				)  
			);  
			$result = file_get_contents($url, 0, $ctx);
		}
		return $result;
	}

	/**
	* @description 签名方法实现,并构造一个参数串
	* 
	* @access private
	* @param mixed $params
	* @return void
	*/
	public  function signRequest($params){
		if ($this->access_token){
			$params[&#39;access_token&#39;] = $this->access_token;
		}
		$keys   = self::urlencodeRfc3986(array_keys($params));
		$values = self::urlencodeRfc3986(array_values($params));
		if($keys and $values){
			$params = array_combine($keys,$values);
		}else{
			throw new Exception("signRequest need params exits!");
		}
		/**
		* 先去除系统级参数
		*/
		unset($params[&#39;appkey&#39;]);
		unset($params[&#39;ts&#39;]); 
		ksort($params);
		/**
		* 第一轮md5字符串
		* */	
		$req   =  md5(http_build_query($params));
		$ts    =  time();/**当次请求的时间戳**/
		/**第二轮md5字符串,得到最后的签名变量,注意里面的顺序不可以改变否则结果错误!**/
		$params[&#39;sign&#39;]   = md5($req.&#39;#&#39;.$this->appkey.&#39;#&#39;.$this->secret.&#39;#&#39;.$ts);
		$params[&#39;appkey&#39;] = $this->appkey;
		$params[&#39;ts&#39;]=$ts;

		return http_build_query($params);
	}

	/**
	* @description 转码异常字符
	* 
	* @access public
	* @param mixed $input
	* @return void
	*/
	public static function urlencodeRfc3986($input){ 
		if (is_array($input)){
			return array_map( array(&#39;open56Client&#39;, &#39;urlencodeRfc3986&#39;) , $input );
		}else if( is_scalar($input)){
			return str_replace( &#39;+&#39; , &#39; &#39; , str_replace( &#39;%7E&#39; , &#39;~&#39; , rawurlencode($input)));
		}else{
			return &#39;&#39;;
		}
	}
}


3. [代码][PHP]代码 

<?php
/**
 * @description PHP SDK for 56 网  v2.0 (include using OAuth2),support by 56 open platform team
 * @
 * /

/**
 * @description 设定时区.
 */
define(&#39;API_TIMEZONE_OFFSET&#39;,8);
if(function_exists(&#39;date_default_timezone_set&#39;)) {
	@date_default_timezone_set(&#39;Etc/GMT&#39;.(API_TIMEZONE_OFFSET > 0 ? &#39;-&#39; : &#39;+&#39;).(abs(API_TIMEZONE_OFFSET)));
} else {
	putenv(&#39;Etc/GMT&#39;.(API_TIMEZONE_OFFSET > 0 ? &#39;-&#39; : &#39;+&#39;).(abs(API_TIMEZONE_OFFSET)));
}

/**
 * @description 常用配置.
 */	   	
error_reporting(E_ALL);
define(&#39;APPKEY&#39;,&#39;1000000010&#39;);
define(&#39;APPSECRET&#39;,&#39;0e4f13954bc537ec&#39;);
/**
 * @description 在oauth认证中请求的token
 */
define(&#39;ACCESS_TOKEN&#39;,&#39;&#39;);
define(&#39;CONNECT_TIMEOUT&#39;, 5);
define(&#39;READ_TIMEOUT&#39;, 5);

/**
 * @description 56网的接口类
 * 
 * @package open56Client
 */
class open56Client extends Exception{

	/**
	* 应用appkey
	*/
	public $appkey; 
	/**
	* 应用secret  
	*/
	public $secret;
	/**
	* 接口访问host
	*/
	public $domain = "http://oapi.56.com";
	/**
	* 用户授权access_token
	*/
	public $access_token;
	/**
	* 是否调试HTTP
	*/
	public $isDebugHttp = false;


	public function __construct($appkey,$secret){
		if(empty($appkey) || empty($secret)){
			try {
				throw new Exception("appkey or secret cannot be empty!");
			} catch(Exception $e) {
				echo $e->getMessage();
			}
		}
		$this->appkey = $appkey;
		$this->secret = $secret;
	}

	/**
	* @description 设置access_token,提供需要oauth授权才能访问的接口设置用户access_token,该值参与客户端签名。
	* 
	* @access public
	* @param mixed $token
	* @return void
	*/
	public function _setToken($token){
		if(!empty($token)){
			$this->access_token = $token;
		}	
		return $this;
	}

	/**
	* @description 简易上传组件地址
	* 
	* return void
	*/
	public function uploadUrl(){
		$url    = $this->domain."/video/upload.plugin";
		$params = array();
		return $url.&#39;?&#39;.self::signRequest($params);
	}

	/**
	* 复杂上传组件地址
	* 
	* @param $sid 第三方的应用的用户名
	* @param $css 获取的样式加密码
	* @param $rurl 失败时跳转的页面,获取返回信息
	* @param $ourl 成功时跳转的页面,获取返回信息
	*/
	public function customUrl($sid, $css, $rurl, $ourl){
		$url    = $this->domain."/video/custom.plugin";
		$params = array(&#39;sid&#39;=> $sid,&#39;css&#39;=> $css ,&#39;rurl&#39;=> $rurl,&#39;ourl&#39;=> $ourl);
		return $url.&#39;?&#39;.self::signRequest($params);
	}

	/**
	* @description 获取视频信息
	* 
	* @param $flvid 56视频的flvid
	* @link /video/getVideoInfo.json
	* @return json
	*/
	public function  getVideoInfoApp($flvid){
		$url    = $this->domain.&#39;/video/getVideoInfo.json&#39;;
		$params = array(&#39;vid&#39;=>$flvid);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获取更新视频信息的接口
	* 
	* @param $flvid 56视频的flvid
	* @param $title 56视频的名称
	* @param $desc  56视频的名称的描述
	* @param $tag   56视频的标签
	* @link  /video/update.json
	* @return json
	*/
	public function  updateApp($flvid,$title,$desc,$tag){
		$url    = $this->domain.&#39;/video/update.json&#39;;
		$params = array(&#39;vid&#39;=>$flvid,&#39;title&#39;=>$title,&#39;desc&#39;=>$desc,&#39;tag&#39;=>$tag);
		return self::getHttp($url,$params);
	}

	/*
	* @description 根据关键字获取搜索结果
	*   $data = array(
	*       &#39;keyword&#39;=> $keyword,  //要查找的关键字
	*       &#39;c&#39;=>1,
	*       &#39;t&#39;=>&#39;month&#39;, 时间,默认为month
	*       &#39;s&#39;=>1,
	*       &#39;page&#39;=>1,     当前页数
	*       &#39;rows&#39;=>$rows, 10 每页显示多少个
	*    );  
	* @param $keyword 主要的字段,关键字搜索,其他的默认即可
	* @link  /video/search.json
	* @return json
	*/
	public function  searchVideo($data){
		$url    = $this->domain.&#39;/video/search.json&#39;;
		$params = array();
		$params = array_merge($params,$data);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获取用户的个人信息
	* 
	* @param $userid 用户在56网站的user_id或视频的flvid
	* @param $token oauth2认证后的令牌
	* @link  /user/userProfile.json
	* @return json
	*/
	public function userInfo($userid){
		$url	= $this->domain.&#39;/user/userProfile.json&#39;;
		$params	= array(&#39;userid&#39;=>$userid,&#39;access_token&#39;=>$token);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获取用户的上传的视频
	* 
	* @param $userid 用户在56网站的user_id或视频的flvid
	* @param $token oauth2认证后的令牌
	* @link  /user/userVideos.json 
	* @return json
	*/
	public function userVideos($userid){
		$url    = $this->domain.&#39;/user/userVideos.json&#39;;
		$params = array(&#39;userid&#39;=>$userid,&#39;access_token&#39;=>$token,&#39;s&#39;=>&#39;time&#39;,&#39;page&#39;=>1,&#39;rows&#39;=>10);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得用户的评论或视频的评论
	* 
	* @param $tid 用户在56网站的user_id或视频的flvid
	* @param $type user/flv
	* @param $token oauth2认证后的令牌
	* @param $pct  1为普通视频 3是相册视频
	* @return json
	*/
	public function userComments($tid = &#39;onesec&#39;, $type = &#39;user&#39;, $pct = 1){
		$url    = $this->domain.&#39;/user/userComments.json&#39;;
		$params = array(&#39;tid&#39;=>$tid,&#39;access_token&#39;=>$token,&#39;type&#39;=> $type,&#39;page&#39;=>1,&#39;rows&#39;=>10, &#39;pct&#39;=> $pct);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得频道的视频
	* 
	* @access public
	* @param string $cid
	* @param string $page
	* @param string $num
	* @return json
	*/
	public function channelVideo($cid = &#39;68&#39;, $page = &#39;1&#39;, $num = &#39;20&#39;){
		$url    = $this->domain.&#39;/video/channel.json&#39;;
		$params = array(&#39;cid&#39;=>$cid, &#39;page&#39;=>$page, &#39;num&#39;=>$num);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得推荐频道的视频
	* 
	* @access public
	* @param string $mid
	* @param string $page
	* @param string $num
	* @return json
	*/
	public function recommendVideo($mid = &#39;16&#39;, $page = &#39;1&#39;, $num = &#39;10&#39;){
		$url    = $this->domain.&#39;/video/recommend.json&#39;;
		$params = array(&#39;mid&#39;=>$mid, &#39;page&#39;=>$page, &#39;num&#39;=>$num);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得56网首页热门的视频
	* 
	* @access public
	* @param string $cid
	* @param string $page
	* @param string $num
	* @return json
	*/
	public function hotVideo($cid = &#39;2&#39;, $page = &#39;1&#39;, $num = &#39;10&#39;){
		$url    = $this->domain.&#39;/video/hot.json&#39;;
		$params = array(&#39;cid&#39;=>$cid, &#39;page&#39;=>$page, &#39;num&#39;=>$num);
		return self::getHttp($url,$params);
	}

	/**
	* @description 获得56网昨天或某天的推荐的相册视频
	* 
	* @access public
	* @param mixed $day
	* @return json|void
	*/
	public function albumVideo($day){
		$url    = $this->domain.&#39;/video/recAlbum.json&#39;;
		$params = array(&#39;day&#39;=>$day);
		return self::getHttp($url,$params);
	}

	/**
	* @description GET 方法
	* 
	* @access private
	* @param mixed $url
	* @param array $params
	* @return json
	*/
	public  function getHttp($url,$params=array()){
		$url = $url.&#39;?&#39;.self::signRequest($params);
		return self::httpCall($url);
	}

	/**
	* @description  POST 方法
	* 
	* @access private
	* @param mixed $url
	* @param mixed $params
	* @return json
	*/
	public  function postHttp($url,$params){
		return self::httpCall($url,self::signRequest($params),&#39;post&#39;);
	}

	/**
	* @description  curl method,post方法params字符串的位置不同于get
	* 
	* @access public
	* @param mixed $url
	* @param string $params
	* @param string $method
	* @param mixed $connectTimeout
	* @param mixed $readTimeout
	* @return json
	*/
	public function httpCall($url ,$params = &#39;&#39;,$method = &#39;get&#39;, $connectTimeout = CONNECT_TIMEOUT, $readTimeout = READ_TIMEOUT) {

		$result = "";
		if (function_exists(&#39;curl_init&#39;)) {
			$timeout = $connectTimeout + $readTimeout;
			/** Use CURL if installed...  **/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $url);
			if (strtolower($method)===&#39;post&#39;){ 
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
			}
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout);
			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_USERAGENT, &#39;56.com API PHP5 Client 1.1 (curl) &#39; . phpversion());
			$result = curl_exec($ch);
		} else{
			if (isset($params) and $params){
				$url = $url."?".http_build_query($params);
			}
		    /** Non-CURL based version... */
			$ctx = stream_context_create(
				array(  
					&#39;http&#39; => array(  
						&#39;timeout&#39; => 5 /** 设置一个超时时间,单位为秒 */
					)  
				)  
			);  
			$result = file_get_contents($url, 0, $ctx);
		}
		return $result;
	}

	/**
	* @description 签名方法实现,并构造一个参数串
	* 
	* @access private
	* @param mixed $params
	* @return void
	*/
	public  function signRequest($params){
		if ($this->access_token){
			$params[&#39;access_token&#39;] = $this->access_token;
		}
		$keys   = self::urlencodeRfc3986(array_keys($params));
		$values = self::urlencodeRfc3986(array_values($params));
		if($keys and $values){
			$params = array_combine($keys,$values);
		}else{
			throw new Exception("signRequest need params exits!");
		}
		/**
		* 先去除系统级参数
		*/
		unset($params[&#39;appkey&#39;]);
		unset($params[&#39;ts&#39;]); 
		ksort($params);
		/**
		* 第一轮md5字符串
		* */	
		$req   =  md5(http_build_query($params));
		$ts    =  time();/**当次请求的时间戳**/
		/**第二轮md5字符串,得到最后的签名变量,注意里面的顺序不可以改变否则结果错误!**/
		$params[&#39;sign&#39;]   = md5($req.&#39;#&#39;.$this->appkey.&#39;#&#39;.$this->secret.&#39;#&#39;.$ts);
		$params[&#39;appkey&#39;] = $this->appkey;
		$params[&#39;ts&#39;]=$ts;

		return http_build_query($params);
	}

	/**
	* @description 转码异常字符
	* 
	* @access public
	* @param mixed $input
	* @return void
	*/
	public static function urlencodeRfc3986($input){ 
		if (is_array($input)){
			return array_map( array(&#39;open56Client&#39;, &#39;urlencodeRfc3986&#39;) , $input );
		}else if( is_scalar($input)){
			return str_replace( &#39;+&#39; , &#39; &#39; , str_replace( &#39;%7E&#39; , &#39;~&#39; , rawurlencode($input)));
		}else{
			return &#39;&#39;;
		}
	}
}

                   

                   

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:中文圆形印章类Artikel seterusnya:两句话将xml字符串转换成数组.