@@ -43,6 +43,12 @@ class Response
43
43
*/
44
44
private $ errorCodes = array ();
45
45
46
+ /**
47
+ * the hostname of the site where the reCAPTCHA was solved
48
+ * @var string
49
+ */
50
+ private $ hostName = '' ;
51
+
46
52
/**
47
53
* Build the response from the expected JSON returned by the service.
48
54
*
@@ -58,7 +64,7 @@ public static function fromJson($json)
58
64
}
59
65
60
66
if (isset ($ responseData ['success ' ]) && $ responseData ['success ' ] == true ) {
61
- return new Response (true );
67
+ return new Response (true , [], isset ( $ responseData [ ' hostname ' ]) ? $ responseData [ ' hostname ' ] : '' );
62
68
}
63
69
64
70
if (isset ($ responseData ['error-codes ' ]) && is_array ($ responseData ['error-codes ' ])) {
@@ -73,11 +79,13 @@ public static function fromJson($json)
73
79
*
74
80
* @param boolean $success
75
81
* @param array $errorCodes
82
+ * @param string $hostname
76
83
*/
77
- public function __construct ($ success , array $ errorCodes = array ())
84
+ public function __construct ($ success , array $ errorCodes = array (), $ hostname = '' )
78
85
{
79
86
$ this ->success = $ success ;
80
87
$ this ->errorCodes = $ errorCodes ;
88
+ $ this ->hostName = $ hostname ;
81
89
}
82
90
83
91
/**
@@ -99,4 +107,12 @@ public function getErrorCodes()
99
107
{
100
108
return $ this ->errorCodes ;
101
109
}
110
+
111
+ /**
112
+ * @return string
113
+ */
114
+ public function getHostName ()
115
+ {
116
+ return $ this ->hostName ;
117
+ }
102
118
}
0 commit comments