目录
回复讨论(解决方案)
首页 后端开发 php教程 PHP识别任何类型的验证码图片

PHP识别任何类型的验证码图片

Jun 23, 2016 pm 01:59 PM

<?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

热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 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

PHP记录:PHP日志分析的最佳实践 PHP记录:PHP日志分析的最佳实践 Mar 10, 2025 pm 02:32 PM

PHP日志记录对于监视和调试Web应用程序以及捕获关键事件,错误和运行时行为至关重要。它为系统性能提供了宝贵的见解,有助于识别问题并支持更快的故障排除

在Laravel中使用Flash会话数据 在Laravel中使用Flash会话数据 Mar 12, 2025 pm 05:08 PM

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

php中的卷曲:如何在REST API中使用PHP卷曲扩展 php中的卷曲:如何在REST API中使用PHP卷曲扩展 Mar 14, 2025 am 11:42 AM

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

简化的HTTP响应在Laravel测试中模拟了 简化的HTTP响应在Laravel测试中模拟了 Mar 12, 2025 pm 05:09 PM

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

在Codecanyon上的12个最佳PHP聊天脚本 在Codecanyon上的12个最佳PHP聊天脚本 Mar 13, 2025 pm 12:08 PM

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

解释PHP中晚期静态结合的概念。 解释PHP中晚期静态结合的概念。 Mar 21, 2025 pm 01:33 PM

文章讨论了PHP 5.3中引入的PHP中的晚期静态结合(LSB),从而允许静态方法的运行时分辨率调用以获得更灵活的继承。 LSB的实用应用和潜在的触摸

自定义/扩展框架:如何添加自定义功能。 自定义/扩展框架:如何添加自定义功能。 Mar 28, 2025 pm 05:12 PM

本文讨论了将自定义功能添加到框架上,专注于理解体系结构,识别扩展点以及集成和调试的最佳实践。

See all articles