PHP identifies any type of verification code Image

Source: Internet
Author: User
PHP recognizes any type of verification code Image. This post was last edited by xiaoxiaoa2 from 2013-06-1512: 45: 48 & lt ;? Php ** Note: This type of function is based on the API interface of the uyou cloud image recognition platform. you can call functions in the class to perform public functions in the image recognition class: & nbsp; setSoftInfo ($ softID, $ soft PHP recognizes any type of verification code Image

This post was last edited by xiaoxiaoa2 at 12:45:48



/**
(This type of function is based on the API interface of the uyou cloud image recognition platform. you can call functions in the class to perform image recognition .)


Public functions in the class:
SetSoftInfo ($ softID, $ softKey); // you can specify the software ID and KEY.
UserLogin ($ userName, $ passWord); // user logon. if logon succeeds, the user ID is returned.
GetPoint ($ userName, $ passWord); // Obtain the remaining User Score
Upload ($ imagePath, $ codeType); // upload based on the image path, return the verification code on the server ID, $ codeType value View: http://www.uuwise.com/price.html
GetResult ($ codeID); // Obtain the recognition result based on the verification code ID
AutoRecognition ($ imagePath, $ codeType); // put upload and getResult in a function for execution and return the verification code recognition result.
ReportError ($ codeID); // An error is returned if the recognition result is incorrect.
RegUser ($ userName, $ userPassword) // register a new user. after successful registration, the ID of the new user is returned.
Pay ($ userName, $ Card); // The score of the top-up question. if the top-up is successful, the current score is returned.

Public variables in the class:
$ MacAddress = '00e021ac7d '; // The mac address of the client, which is not used by the server at the moment. the method for assigning values to the bound mac address is as follows: $ obj-> macAddress = '00e021ac7d ';
$ TimeOut = '000000'; // timeOut Time. do not change the value assignment method: $ obj-> timeOut = 60000;

Function call method:
You must first create an object.
$ Obj = new uuApi;
$ Obj-> setSoftInfo ('20140901', 'b7ee76f547e34516bc30f6eb6c67c7db'); // How do I obtain these two values? Please check this page: 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 '; // The mac address of the client, which is not used by the server at the moment. the method for assigning values to the bound mac address is as follows: $ obj-> macAddress = '00e021ac7d ';
Public $ timeOut = 60000; // timeOut. do not change the value assignment method: $ 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' => '123 ',
);
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 ))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.