Skip to content

Commit

Permalink
minor fix condition code
Browse files Browse the repository at this point in the history
  • Loading branch information
tojo-r27 committed Jul 9, 2021
1 parent 68cc472 commit 2d047a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ Create an account on https://www.hcaptcha.com for having `secret_key` and `site_
$response = Hcaptcha::verify($request->get('h-captcha-response'));
//add condition for response
if($response == 200){
return "Test OK";
if($response){
$msg = "Robot verification success";
}else{
return "Test failed";
$msg = "Robot verification failed";
}
**License**
Expand Down
11 changes: 3 additions & 8 deletions src/Hcaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@ public static function verify($response) {

try {
$res = $client->request('POST', 'https://hcaptcha.com/siteverify', $data);

$res = response()->json([
'status' => $res->getStatusCode(),
'message' => $res->getReasonPhrase()
]);
$json = json_encode($res);
$json = json_decode($json, true);
return $json['original'];
$body = $res->getBody();
$json = json_decode($body);
return $json;
} catch(\Exception $e) {
return response()->json(['error' => $e->getMessage()]);
}
Expand Down

0 comments on commit 2d047a5

Please sign in to comment.