搜尋
首頁後端開發php教程PHP识别任何类型的验证码图片

<?php/**	说明:此类函数是基于优优云图片识别平台的API接口,调用类中的函数可以进行图片识别		类中的公有函数:		 setSoftInfo($softID,$softKey);				//设置软件ID和KEY		 userLogin($userName,$passWord);			//用户登录,登录成功返回用户的ID		 getPoint($userName,$passWord);				//获取用户剩余题分		 upload($imagePath,$codeType);				//根据图片路径上传,返回验证码在服务器的ID,$codeType取值查看:http://www.uuwise.com/price.html		 getResult($codeID);						//根据验证码ID获取识别结果		 autoRecognition($imagePath,$codeType);		//将upload和getResult放到一个函数来执行,返回验证码识别结果		 reportError($codeID);						//识别结果不正确报错误		 regUser($userName,$userPassword)			//注册新用户,注册成功返回新用户的ID		 pay($userName,$Card);						//充值题分,充值成功返回用户当前题分		类中的公有变量:		 $macAddress='00e021ac7d';					//客户机的mac地址,服务器暂时没有用,后期准备用于绑定mac地址		赋值方法: $obj->macAddress='00e021ac7d'; 		 $timeOut='60000';							//超时时间,建议不要改动此值									赋值方法: $obj->timeOut=60000;		 	函数调用方法:		 需要先new一个对象		 $obj=new uuApi;		 $obj->setSoftInfo('2097','b7ee76f547e34516bc30f6eb6c67c7db');	//如何获取这两个值?请查看这个页面:http://dll.uuwise.com/index.php?n=ApiDoc.GetSoftIDandKEY		 $obj->userLogin('userName','userPassword');		 $result=autoRecognition($imagePath,$codeType);		*/class uuApi{		private $softID;	private $softKEY;	private $userName;	private $userPassword;		private $uid;	private $userKey;	private $softContentKEY;		private $uuUrl;	private $uhash;	private $uuVersion='1.1.0.1';	private $userAgent;	private $gkey;		public $macAddress='00e021ac7d';	//客户机的mac地址,服务器暂时没有用,后期准备用于绑定mac地址		赋值方法: $obj->macAddress='00e021ac7d'; 	public $timeOut=60000;				//超时时间,建议不要改动此值									赋值方法: $obj->timeOut=60000;		public function setSoftInfo($id,$key)	{		if($id&&$key){			$this->softID=$id;			$this->softKEY=$key;			$this->uhash=md5($id.strtoupper($key));			return 'YES';		}		return 'NO';	}	private function getServerUrl($Server)	{		$url = "http://common.taskok.com:9000/Service/ServerConfig.aspx";		$result=$this->uuGetUrl($url,array(),$postData=false);		preg_match_all("/\,(.*?)\:101\,(.*?)\:102\,(.*?)\:103/", $result, $match_index);		$arr=array_filter($match_index);		if(empty($arr)){return '-1001';}		switch($Server)		{			case 'service':				return 'http://'.$match_index[1][0];				break;			case 'upload':				return 'http://'.$match_index[2][0];				break;			case 'code':				return 'http://'.$match_index[3][0];				break;			default:				return 'parameter error';		}		curl_close($this->uuUrl);	}	public function userLogin($userName,$passWord)	{		if(!($this->softID&&$this->softKEY))		{			return 'sorry,SoftID or softKey is not set! Please use the setSoftInfo(id,key) function to set!';		}		if(!($userName&&$passWord)){ return 'userName or passWord is empty!';}		$this->userName=$userName;		$this->userPassword=$passWord;		$this->userAgent=md5(strtoupper($this->softKEY).strtoupper($this->userName)).$this->macAddress;				$url = $this->getServerUrl('service').'/Upload/Login.aspx?U='.$this->userName.'&P='.md5($this->userPassword).'&R='.mktime();		$result=$this->uuGetUrl($url);				if($result>0)		{			$this->userKey=$result;			$this->uid=explode("_",$this->userKey);			$this->uid=$this->uid[0];			$this->softContentKEY=md5(strtolower($this->userKey.$this->softID.$this->softKEY));			$this->gkey=md5(strtoupper($this->softKEY.$this->userName)).$this->macAddress;			return $this->uid;		}		return $result;	}	public function getPoint($userName,$passWord)	{		if(!($userName&&$passWord)){ return 'userName or passWord is empty!';}		$url = $this->getServerUrl('service').'/Upload/GetScore.aspx?U='.$userName.'&P='.md5($passWord).'&R='.mktime();		$result=$this->uuGetUrl($url);		return $result;	}	public function upload($imagePath,$codeType,$auth=false)	{		if(!file_exists($imagePath)){return '-1003';}		if(!is_numeric($codeType)){return '-3004';}		$data=array(			'img'=>'@'.$imagePath,			'key'=>$this->userKey,			'sid'=>$this->softID,			'skey'=>$this->softContentKEY,			'TimeOut'=>$this->timeOut,			'Type'=>$codeType		);		$ver=array(			'Version'=>'100',		);		if($auth){$data=$data+$ver;}		$url = $this->getServerUrl('upload').'/Upload/Processing.aspx?R='.mktime();		return $this->uuGetUrl($url,$data);	}	public function getResult($codeID)	{		if(!is_numeric($codeID)){return '-1009|The codeID is not number';}		$url = $this->getServerUrl('code').'/Upload/GetResult.aspx?KEY='.$this->userKey.'&ID='.$codeID.'&Random='.mktime();		$result='-3';		$timer=0;		while($result=='-3'&&($timer<$this->timeOut))		{			$result=$this->uuGetUrl($url,false,false);			usleep(100000);		}		curl_close($this->uuUrl);		if($result=='-3')		{			return '-1002';			}		return $result;	}	public function autoRecognition($imagePath,$codeType)	{		$result=$this->upload($imagePath,$codeType,$auth=true);		if($result>0){			$arrayResult=explode("|",$result);			if(!empty($arrayResult[1])){return $arrayResult[1];}			return $this->getResult($result);		}		return $result;	}	private function uuGetUrl($url,$postData=false,$closeUrl=true)	{		$uid=isset($this->uid)?($this->uid):'100';		$default=array(			'Accept: text/html, application/xhtml+xml, */*',			'Accept-Language: zh-CN',			'Connection: Keep-Alive',			'Cache-Control: no-cache',			'SID:'.$this->softID,			'HASH:'.$this->uhash,			'UUVersion:'.$this->uuVersion,			'UID:'.$uid,			'User-Agent:'.$this->userAgent,			'KEY:'.$this->gkey,		);		$this->uuUrl = curl_init();		curl_setopt($this->uuUrl, CURLOPT_HTTPHEADER, ($default));		curl_setopt($this->uuUrl, CURLOPT_HEADER, false);		curl_setopt($this->uuUrl, CURLOPT_RETURNTRANSFER, true);		curl_setopt($this->uuUrl, CURLOPT_FOLLOWLOCATION, true);		curl_setopt($this->uuUrl, CURLOPT_VERBOSE, false);		curl_setopt($this->uuUrl, CURLOPT_TIMEOUT, $this->timeOut);		curl_setopt($this->uuUrl, CURLOPT_AUTOREFERER, true);		curl_setopt($this->uuUrl, CURLOPT_RETURNTRANSFER, true);		curl_setopt($this->uuUrl, CURLOPT_HTTPGET, true);		curl_setopt($this->uuUrl, CURLOPT_URL,$url);		if($postData)		{			curl_setopt($this->uuUrl, CURLOPT_POST, true);			curl_setopt($this->uuUrl, CURLOPT_POSTFIELDS, $postData);		}		$info=curl_exec($this->uuUrl);		if($closeUrl){			curl_close($this->uuUrl);		}		return trim($info);	}	public function reportError($codeID)	{		if(!is_numeric($codeID)){return '-1009|The codeID is not number';}		if($this->softContentKEY&&$this->userKey)		{			$url = $this->getServerUrl('code').'/Upload/ReportError.aspx?key='.$this->userKey.'&ID='.$codeID.'&sid='.$this->softID.'&skey='.$this->softContentKEY.'&R='.mktime();			$result=$this->uuGetUrl($url);			if($result=='OK')			{				return 'OK';				}			return $result;		}		return '-1';	}	public function regUser($userName,$userPassword)	{		if($this->softID&&$this->softKEY)		{			if($userName&&$userPassword)			{				$data=array(					'U'=>$userName,					'P'=>$userPassword,					'sid'=>$this->softID,					'UKEY'=>md5(strtoupper($userName).$userPassword.$this->softID.strtolower($this->softKEY)),				);				$url=$this->getServerUrl('service').'/Service/Reg.aspx';				return $this->uuGetUrl($url,$data);			}			return 'userName or userPassword is empty!';		}		return '-1';	}		public function pay($userName,$Card)	{		if($this->softID&&$this->softKEY)		{			if($userName&&$Card)			{				$data=array(					'U'=>$userName,					'card'=>$Card,					'sid'=>$this->softID,					'pkey'=>md5(strtoupper($userName).$this->softID.$this->softKEY.strtoupper($Card)),				);				$url=$this->getServerUrl('service').'/Service/Pay.aspx';				return $this->uuGetUrl($url,$data);			}			return 'userName or Card is empty!';		}		return '-1';		}}?>


终于研究出来他们的API了,
现在识别基本是万能的,测试图片


回复讨论(解决方案)

广告贴?百度了一下这个公司,很明显是人工识别。

保留怀疑意见~~

请识别验证码图片:s+b=?

60秒时间,是不是太长了,而且这个在哪里可以用到呢?这个耗的资源更多

有一种职业,叫网络打字员

还是很有用处的

60秒时间,是不是太长了,而且这个在哪里可以用到呢?这个耗的资源更多

抢火车票,抢小米,各种啊

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
PHP與Python:了解差異PHP與Python:了解差異Apr 11, 2025 am 12:15 AM

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

php:死亡還是簡單地適應?php:死亡還是簡單地適應?Apr 11, 2025 am 12:13 AM

PHP不是在消亡,而是在不斷適應和進化。 1)PHP從1994年起經歷多次版本迭代,適應新技術趨勢。 2)目前廣泛應用於電子商務、內容管理系統等領域。 3)PHP8引入JIT編譯器等功能,提升性能和現代化。 4)使用OPcache和遵循PSR-12標準可優化性能和代碼質量。

PHP的未來:改編和創新PHP的未來:改編和創新Apr 11, 2025 am 12:01 AM

PHP的未來將通過適應新技術趨勢和引入創新特性來實現:1)適應云計算、容器化和微服務架構,支持Docker和Kubernetes;2)引入JIT編譯器和枚舉類型,提升性能和數據處理效率;3)持續優化性能和推廣最佳實踐。

您什麼時候使用特質與PHP中的抽像類或接口?您什麼時候使用特質與PHP中的抽像類或接口?Apr 10, 2025 am 09:39 AM

在PHP中,trait適用於需要方法復用但不適合使用繼承的情況。 1)trait允許在類中復用方法,避免多重繼承複雜性。 2)使用trait時需注意方法衝突,可通過insteadof和as關鍵字解決。 3)應避免過度使用trait,保持其單一職責,以優化性能和提高代碼可維護性。

什麼是依賴性注入容器(DIC),為什麼在PHP中使用一個?什麼是依賴性注入容器(DIC),為什麼在PHP中使用一個?Apr 10, 2025 am 09:38 AM

依賴注入容器(DIC)是一種管理和提供對象依賴關係的工具,用於PHP項目中。 DIC的主要好處包括:1.解耦,使組件獨立,代碼易維護和測試;2.靈活性,易替換或修改依賴關係;3.可測試性,方便注入mock對象進行單元測試。

與常規PHP陣列相比,解釋SPL SplfixedArray及其性能特徵。與常規PHP陣列相比,解釋SPL SplfixedArray及其性能特徵。Apr 10, 2025 am 09:37 AM

SplFixedArray在PHP中是一種固定大小的數組,適用於需要高性能和低內存使用量的場景。 1)它在創建時需指定大小,避免動態調整帶來的開銷。 2)基於C語言數組,直接操作內存,訪問速度快。 3)適合大規模數據處理和內存敏感環境,但需謹慎使用,因其大小固定。

PHP如何安全地上載文件?PHP如何安全地上載文件?Apr 10, 2025 am 09:37 AM

PHP通過$\_FILES變量處理文件上傳,確保安全性的方法包括:1.檢查上傳錯誤,2.驗證文件類型和大小,3.防止文件覆蓋,4.移動文件到永久存儲位置。

什麼是無效的合併操作員(??)和無效分配運算符(?? =)?什麼是無效的合併操作員(??)和無效分配運算符(?? =)?Apr 10, 2025 am 09:33 AM

JavaScript中處理空值可以使用NullCoalescingOperator(??)和NullCoalescingAssignmentOperator(??=)。 1.??返回第一個非null或非undefined的操作數。 2.??=將變量賦值為右操作數的值,但前提是該變量為null或undefined。這些操作符簡化了代碼邏輯,提高了可讀性和性能。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境