: This article mainly introduces PHP restrictions on frequent requests. For more information about PHP tutorials, see.
* @ Link http://www.jieone.com/ */Class Token extends RSA {/*** unique client ID */private $ date = 0; private $ clientID = "abccccc";/*** system access_token, that is, the data to be saved on the client */private function sys_access_token () {$ array = array ('clientid' => $ this-> clientID, 'date' => $ this-> date); $ sys_access_token = json_encode ($ array); // RSA public key encryption return $ this-> public_encrypt ($ sys_access_token );} /*** save access_token */public function get_access_token () {if (empty ($ _ COOKIE ['Access _ token']) {$ this-> date = time () -100; return $ this-> sys_access_token ();} return $ _ COOKIE ['Access _ token'];}/*** save access_token */private function save_access_token () {setcookie ("access_token", $ this-> sys_access_token ();} public function check () {$ access_token = $ this-> get_access_token (); // RSA private key decryption $ access_token = $ this-> private_decrypt ($ access_token); // The information has been illegally tampered with if (empty ($ access_token) {return false ;} $ object = json_decode ($ access_token); // ajax requests can be requested only once in 2 seconds. you can modify if ($ object-> date + 2> time () {return false ;} // save access_token $ this-> date = time (); $ this-> save_access_token (); return true ;}} echo'
Try refreshing frequently
'; $ Token = new Token (); if (! $ Token-> check () {echo'
Your request is too fast. please try again later
'; Exit ();} echo'
Access normal
'; Echo "your current access_token:". $ Token-> get_access_token ();
The above section describes the restrictions on frequent requests in PHP, including some content, and hopes to help those who are interested in PHP tutorials.