好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁(yè) > 知識(shí)庫(kù) > PHP封裝curl的調(diào)用接口及常用函數(shù)詳解

PHP封裝curl的調(diào)用接口及常用函數(shù)詳解

熱門(mén)標(biāo)簽:h5 地圖標(biāo)注 合肥外呼系統(tǒng)app 智能外呼電銷(xiāo)系統(tǒng) 高識(shí)別電銷(xiāo)機(jī)器人 哈爾濱400電話(huà)辦理到易號(hào)網(wǎng) 沈陽(yáng)人工智能電銷(xiāo)機(jī)器人公司 電銷(xiāo)機(jī)器人-快迭智能 拉薩打電話(huà)機(jī)器人 寶安400電話(huà)辦理

如下所示:

?php
	/**
	 * @desc 封裝curl的調(diào)用接口,post的請(qǐng)求方式
	 */
	function doCurlPostRequest($url, $requestString, $timeout = 5) { 
		if($url == "" || $requestString == "" || $timeout = 0){
			return false;
		}
		 $con = curl_init((string)$url);
	 curl_setopt($con, CURLOPT_HEADER, false);
	 curl_setopt($con, CURLOPT_POSTFIELDS, $requestString);
	 curl_setopt($con, CURLOPT_POST, true);
	 curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
	 curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout);
		curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($con, CURLOPT_SSL_VERIFYHOST, false);
	 return curl_exec($con);
	}
	
	/**
	 * @desc 封裝curl的調(diào)用接口,post的請(qǐng)求方式
	 */
	function doCurlPostsslRequest($url, $requestString,$pemfile, $timeout = 5) { 
		if($url == "" || $requestString == "" || $timeout = 0){
			return false;
		}
		
		echo $pemfile;
		 $con = curl_init((string)$url);
	 curl_setopt($con, CURLOPT_HEADER, false);
	 curl_setopt($con, CURLOPT_POSTFIELDS, $requestString);
	 curl_setopt($con, CURLOPT_POST, true);
	 curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
	 curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout);
		curl_setopt($con, CURLOPT_SSL_VERIFYPEER, 1);
		curl_setopt($con, CURLOPT_SSL_VERIFYHOST, 2);
		//curl_setopt($ch, CURLOPT_SSLCERT, $pemfile); 
		//curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
		curl_setopt($con, CURLOPT_CAINFO, $pemfile);
	 return curl_exec($con);
	} 
	/**
	 * @desc 封裝curl的調(diào)用接口,post Json數(shù)據(jù)的請(qǐng)求方式
	 */
	function doCurlPostJsonReq($url, $requestString, $timeout = 25){
		if($url == "" || $requestString == "" || $timeout = 0){
			return false;
		}
	 $con = curl_init((string)$url);
	 curl_setopt($con, CURLOPT_HEADER, false);
	 curl_setopt($con, CURLOPT_POSTFIELDS, $requestString);
	 curl_setopt($con, CURLOPT_POST, true);
	 curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
	 curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout);	
		curl_setopt($con, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/json',
			'Content-Length: ' . strlen($data_string))
		);
	 return curl_exec($con);
	}
	/**
	 * @desc 封裝curl的調(diào)用接口,post form數(shù)據(jù)的請(qǐng)求方式
	 */
	function doCurlPostFormReq($url, $requestString, $timeout = 25){
		if($url == "" || $requestString == "" || $timeout = 0){
			return false;
		}
	 $con = curl_init((string)$url);
	 curl_setopt($con, CURLOPT_HEADER, false);
	 curl_setopt($con, CURLOPT_POSTFIELDS, $requestString);
	 curl_setopt($con, CURLOPT_POST, true);
	 curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
	 curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout);	
		curl_setopt($con, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/x-www-form-urlencoded')
		);
	 return curl_exec($con);
	}
	/**
	 * @desc 封裝curl的調(diào)用接口,get的請(qǐng)求方式
	 */
	function doCurlGetRequest($url, $data = array(), $timeout = 10) {
		if($url == "" || $timeout = 0){
			return false;
		}
		if($data != array()) {
			$url = $url . '?' . http_build_query($data);
		}
		Log::write("發(fā)送URL[".$url."]");
		$con = curl_init((string)$url);
		curl_setopt($con, CURLOPT_HEADER, false);
		curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
		curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout);
		curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($con, CURLOPT_SSL_VERIFYHOST, false);
		return curl_exec($con);
	}
	/**
	 *截取字符串,中文無(wú)亂碼
	*/
	function msubstr($str, $start=0, $length=0,$suffix=false,$charset="utf-8"){
	 if(mb_strlen($str,"UTF8") >= $length){
	  $next_str = "…";
	 }else{
	  $next_str = "";
	 }
	 if(function_exists("mb_substr")){
	  if($suffix)
	   // return mb_substr($str, $start, $length, $charset)."…";
	   return mb_substr($str, $start, $length, $charset).$next_str;
	  else
	   return mb_substr($str, $start, $length, $charset);
	 }elseif(function_exists('iconv_substr')) {
	  if($suffix)
	   // return iconv_substr($str,$start,$length,$charset)."…";
	   return iconv_substr($str,$start,$length,$charset).$next_str;
	  else
	   return iconv_substr($str,$start,$length,$charset);
	 }
	 $re['utf-8'] = "/[x01-x7f]|[xc2-xdf][x80-xbf]|[xe0-xef][x80-xbf]{2}|[xf0-xff][x80-xbf]{3}/";
	 $re['gb2312'] = "/[x01-x7f]|[xb0-xf7][xa0-xfe]/";
	 $re['gbk'] = "/[x01-x7f]|[x81-xfe][x40-xfe]/";
	 $re['big5'] = "/[x01-x7f]|[x81-xfe]([x40-x7e]|xa1-xfe])/";
	 preg_match_all($re[$charset], $str, $match);
	 $slice = join("",array_slice($match[0], $start, $length));
	  if($suffix) return $slice."…";
	 if(!$suffix) return $slice;
	 return $slice;
	}
	/**
	 *用戶(hù)名*隱藏
	 *$str = "如來(lái)神掌";
	 *echo cut_str($str, 1, 0).'**'.cut_str($str, 1, -1);
	 *輸出:如**掌
	*/
	function cut_str($string, $sublen, $start = 0, $code = 'UTF-8')
	{
	 if($code == 'UTF-8')
	 {
	  $pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
	  preg_match_all($pa, $string, $t_string);
	  if(count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen));
	  return join('', array_slice($t_string[0], $start, $sublen));
	 }
	 else
	 {
	  $start = $start*2;
	  $sublen = $sublen*2;
	  $strlen = strlen($string);
	  $tmpstr = '';
	  for($i=0; $i $strlen; $i++)
	  {
	   if($i>=$start  $i ($start+$sublen))
	   {
	    if(ord(substr($string, $i, 1))>129)
	    {
	     $tmpstr.= substr($string, $i, 2);
	    }
	    else
	    {
	     $tmpstr.= substr($string, $i, 1);
	    }
	   }
	   if(ord(substr($string, $i, 1))>129) $i++;
	  }
	  //if(strlen($tmpstr) $strlen ) $tmpstr.= "...";
	  return $tmpstr;
	 }
	}
	/*
	*解決json_encode轉(zhuǎn)換中文的問(wèn)題,在php5.4下json_encode本身解決的這個(gè)問(wèn)題
	*/
	function unescapedUnicode($match)
	{
		return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
	}
	/**
	*截取手機(jī)號(hào)
	*demo:13112345678
	*return:131****5678
	*/
	function hidtel($phone){
	 $IsWhat = preg_match('/(0[0-9]{2,3}[-]?[2-9][0-9]{6,7}[-]?[0-9]?)/i',$phone); //固定電話(huà)
	 if($IsWhat == 1){
	  return preg_replace('/(0[0-9]{2,3}[-]?[2-9])[0-9]{3,4}([0-9]{3}[-]?[0-9]?)/i','$1****$2',$phone);
	 }else{
	  return preg_replace('/(1[358]{1}[0-9])[0-9]{4}([0-9]{4})/i','$1****$2',$phone);
	 }
	}
	//獲取IP
	function getIp()
	{
		if (isset($_SERVER)){
			if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
				$realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
			} else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
				$realip = $_SERVER["HTTP_CLIENT_IP"];
			} else {
				$realip = $_SERVER["REMOTE_ADDR"];
			}
		} else {
			if (getenv("HTTP_X_FORWARDED_FOR")){
				$realip = getenv("HTTP_X_FORWARDED_FOR");
			} else if (getenv("HTTP_CLIENT_IP")) {
				$realip = getenv("HTTP_CLIENT_IP");
			} else {
				$realip = getenv("REMOTE_ADDR");
			}
		}
	
		return $realip;
	}
	//把漢字轉(zhuǎn)換為數(shù)字
	function getUnicodeFromOneUTF8($word)
	{
		//獲取其字符的內(nèi)部數(shù)組表示,所以本文件應(yīng)用utf-8編碼! 
		//$word = iconv("gb2312", "utf-8", $word);
		if (is_array($word)) 
			$arr = $word; 
		else 
			$arr = str_split($word); 
		//此時(shí),$arr應(yīng)類(lèi)似array(228, 189, 160) 
		//定義一個(gè)空字符串存儲(chǔ) 
		$bin_str = ''; 
		//轉(zhuǎn)成數(shù)字再轉(zhuǎn)成二進(jìn)制字符串,最后聯(lián)合起來(lái)。 
		foreach ($arr as $value) 
			$bin_str .= decbin(ord($value)); 
		//此時(shí),$bin_str應(yīng)類(lèi)似111001001011110110100000
		//正則截取 
		$bin_str = preg_replace('/^.{4}(.{4}).{2}(.{6}).{2}(.{6})$/','$1$2$3', $bin_str);
		//此時(shí), $bin_str應(yīng)類(lèi)似0100111101100000,如果是漢字"你"
		return bindec($bin_str); 
		//返回類(lèi)似20320, 漢字"你" 
		//return dechex(bindec($bin_str)); 
		//如想返回十六進(jìn)制4f60,用這句 

以上這篇PHP封裝curl的調(diào)用接口及常用函數(shù)詳解就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • php的curl封裝類(lèi)用法實(shí)例
  • php實(shí)現(xiàn)的Curl封裝類(lèi)Curl.class.php用法實(shí)例分析
  • php異步:在php中使用fsockopen curl實(shí)現(xiàn)類(lèi)似異步處理的功能方法
  • PHP封裝CURL擴(kuò)展類(lèi)實(shí)例
  • php基于curl實(shí)現(xiàn)的股票信息查詢(xún)類(lèi)實(shí)例
  • PHP實(shí)現(xiàn)的CURL非阻塞調(diào)用類(lèi)
  • php curl操作API接口類(lèi)完整示例
  • 淺談PHP封裝CURL
  • PHP封裝cURL工具類(lèi)與應(yīng)用示例

標(biāo)簽:成都 巴中 林芝 山東 威海 梅州 張家口 泰州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP封裝curl的調(diào)用接口及常用函數(shù)詳解》,本文關(guān)鍵詞  PHP,封裝,curl,的,調(diào)用,接口,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PHP封裝curl的調(diào)用接口及常用函數(shù)詳解》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于PHP封裝curl的調(diào)用接口及常用函數(shù)詳解的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 国产熟女丝袜AV一二区| 山村女人一级毛片免费播放| 亚洲深夜在线| 国产精品资源| 男男啪啪网站| 91精品国产一区二区三区香蕉| 国产欧美日韩精品专区黑人| 日产精品人妻久久毛片二之野外 | yjizz国产在线视频网| 免费人成黄页在线观看日本| 羞羞色| 好大?用力?深一点高潮学校| 超大乳抖乳露双乳喷奶水视频| 娜露价值599挤奶视频06| 宅宅韩国伦三级236| 国产AV无遮挡喷水白浆铁牛视频| 天天躁日日躁狠狠躁到发狂| 美女扒开粉嫩尿口的照片| 免费看av的网址| pANs模特小雪大尺度内部收费私拍| 国产日日操| 伦理三级电影在线观看| 日韩一区在线视频| 亚洲一级Av无码毛片久久精品1 | 92午夜免费福利757永久| 专情男主偷欲出轨h| 亚洲Av中文字幕不卡在线| 亚洲精品无圣光一区二区| 恋老old300| 香蕉app成人版下载| 公妇激情系列小说| 久久99久久| 国产一a毛一a毛A免费看图| 三上悠亚车牌| 国产精品福利在线观看秒播 | 曰本女人囗交视频| 大佬塞玩具无法走路视频| 农村同性壮汉肉合集| 每天含着玉势走路高H文| 暴露调教跪趴玉势| 边摸边做大尺度床戏|