TencentCaptchaService.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Services\Common;
  3. use Illuminate\Support\Facades\Cache;
  4. class TencentCaptchaService{
  5. private $appId = 'kJuJadQt';
  6. private $appKey = 'QPk34Fzi';
  7. private $AppSecretKey = '5wWzxbiTgcREfZVMAj3m1PoZC';
  8. private $CaptchaAppId = '196587903';
  9. protected $client;
  10. public function __construct()
  11. {
  12. $this->client = new CurlService();
  13. }
  14. public function check($RendStr, $Ticket, $ip)
  15. {
  16. if (empty($RendStr) || empty($Ticket) || empty($ip)) {
  17. return false;
  18. }
  19. $data= [
  20. 'appId' => $this->appId,
  21. 'appKey' => $this->appKey,
  22. 'AppSecretKey' => $this->AppSecretKey,
  23. 'CaptchaAppId' => $this->CaptchaAppId,
  24. 'RendStr' => $RendStr,
  25. 'Ticket' => $Ticket,
  26. 'IP' => $ip
  27. ];
  28. $res = $this->client->post("https://api.253.com/open/txyzm/yzm-v2",$data);
  29. if($res->code == '200000' && $res->data['CaptchaMsg'] == "OK"){
  30. return true;
  31. }else{
  32. return false;
  33. }
  34. }
  35. }