Returns whether the given response was successful.

@param string $response The form's 'g-recaptcha-response' field value.

@return bool
767988
public function verify($response)
    {
        $result = $this->getVerificationResult($response);

        if ($result['success']) {
            return true;
        }

        if (!empty($result['error-codes'])) {
            $this->errors = $result['error-codes'];
        }

        return false;
    }
198329
public function validateResponse(array $response)
    {
        $returnValue = false;
        if (isset($response['header'])
            && isset($response['header']['status'])
            && $response['header']['status'] >= 200
            && $response['header']['status'] < 300
        ) {
            $returnValue = true;
        }

        return $returnValue;
    }
1074102
public function verify($reCaptchaResponse, $remoteIp = null)
    {
        $options = ['secret' => $this->clientSecret, 'response' => $reCaptchaResponse];

        if (null !== $remoteIp) {
            $options['remoteip'] = $remoteIp;
        }

        $result = $this->request('siteverify', $options, 'POST');
        $this->lastErrors = isset($result['error-codes']) ? $result['error-codes'] : [];

        return $result['success'];
    }
1047826
private function checkResponse($response)
    {
        $hasRequestError = false;
        if (preg_match('/4\d\d/', $response->getStatusCode())) {
            $this->log('error', "Invalid API key or password");
            $this->addError(self::ERROR_HTTP_AUTHENTICATION_ERROR, false);
            $hasRequestError = true;
        } elseif (preg_match('/5\d\d/', $response->getStatusCode())) {
            $this->log('error', "Gateway error - HTTP " . $response->getStatusCode());
            $this->addError(self::ERROR_HTTP_SERVER_ERROR);
            $hasRequestError = true;
        } elseif ($response->getError()) {
            $this->log('error', "Connection error: " . $response->getError());
            $this->addError(self::ERROR_CONNECTION_ERROR);
            $hasRequestError = true;
        }

        if ($hasRequestError) {
            throw new RequestException(sprintf("Last HTTP response status code: %s", $response->getStatusCode()));
        }
    }
214594
public static function getNextResult(&$response)
    {
        //====================================================================//
        // Extract Next Task From Buffer
        $task = self::getNextTask($response);
        //====================================================================//
        // Analyze SOAP Results
        if (!$task || !isset($task->data)) {
            return false;
        }
        //====================================================================//
        // Return Task Data
        return $task->data;
    }
93288
public function execute($response) {
        global $CFG, $DB;

        $params = $this->parse_template();
        $contextid = $params['context_id'];
        $itemid = $params['item_id'];

        // GET is disabled by the moment, but we have the code ready
        // for a future implementation.

        $isget = $response->get_request_method() === 'GET';
        if ($isget) {
            $contenttype = $response->get_accept();
        } else {
            $contenttype = $response->get_content_type();
        }
        $container = empty($contenttype) || ($contenttype === $this->formats[0]);
        // We will receive typeid when working with LTI 1.x, if not the we are in LTI 2.
        $typeid = optional_param('type_id', null, PARAM_ALPHANUM);
        if (is_null($typeid)) {
            if (!$this->check_tool_proxy(null, $response->get_request_data())) {
                $response->set_code(403);
                return;
            }
        } else {
            switch ($response->get_request_method()) {
                case 'GET':
                    $response->set_code(405);
                    $response->set_reason("GET requests are not allowed.");
                    return;
                case 'POST':
                    if (!$this->check_type($typeid, $contextid, 'Score.collection:post', $response->get_request_data())) {
                        $response->set_code(401);
                        $response->set_reason("This resource does not support POST requests.");
                        return;
                    }
                    break;
                default:  // Should not be possible.
                    $response->set_code(405);
                    return;
            }
        }
        if (empty($contextid) || !($container ^ ($response->get_request_method() === 'POST')) ||
                (!empty($contenttype) && !in_array($contenttype, $this->formats))) {
            $response->set_code(400);
            return;
        }
        if (!$DB->record_exists('course', array('id' => $contextid))) {
            $response->set_code(404);
            $response->set_reason("Not Found: Course $contextid doesn't exist.");
            return;
        }
        if (!$DB->record_exists('grade_items', array('id' => $itemid))) {
            $response->set_code(404);
            $response->set_reason("Not Found: Grade item $itemid doesn't exist.");
            return;
        }
        $item = $this->get_service()->get_lineitem($contextid, $itemid, $typeid);
        if ($item === false) {
            $response->set_code(403);
            $response->set_reason("Line item does not exist.");
            return;
        }
        $gbs = gradebookservices::find_ltiservice_gradebookservice_for_lineitem($itemid);
        $ltilinkid = null;
        if (isset($item->iteminstance)) {
            $ltilinkid = $item->iteminstance;
        } else if ($gbs && isset($gbs->ltilinkid)) {
            $ltilinkid = $gbs->ltilinkid;
        }
        if ($ltilinkid != null) {
            if (is_null($typeid)) {
                if (isset($item->iteminstance) && (!gradebookservices::check_lti_id($ltilinkid, $item->courseid,
                        $this->get_service()->get_tool_proxy()->id))) {
                    $response->set_code(403);
                    $response->set_reason("Invalid LTI id supplied.");
                    return;
                }
            } else {
                if (isset($item->iteminstance) && (!gradebookservices::check_lti_1x_id($ltilinkid, $item->courseid,
                        $typeid))) {
                    $response->set_code(403);
                    $response->set_reason("Invalid LTI id supplied.");
                    return;
                }
            }
        }
        $json = '[]';
        require_once($CFG->libdir.'/gradelib.php');
        switch ($response->get_request_method()) {
            case 'GET':
                $response->set_code(405);
                $response->set_reason("GET requests are not allowed.");
                break;
            case 'POST':
                try {
                    $json = $this->get_json_for_post_request($response, $response->get_request_data(), $item, $contextid, $typeid);
                    $response->set_content_type($this->formats[1]);
                } catch (\Exception $e) {
                    $response->set_code($e->getCode());
                    $response->set_reason($e->getMessage());
                }
                break;
            default:  // Should not be possible.
                $response->set_code(405);
                $response->set_reason("Invalid request method specified.");
                return;
        }
        $response->set_body($json);
    }
677511
public static function isJsonError($response)
    {

        if(is_wp_error($response)) {
            return true; 
        }

        if ($decoded = json_decode($response)) {
            $response = (array) $decoded;
        }

        if (isset($response['error'])) {
            return true;
        }
        
        return false;
    }
72569
static function verify($secret,$response=NULL) {
		$fw=\Base::instance();
		if (!isset($response))
			$response=$fw->{'POST.g-recaptcha-response'};
		if (!$response)
			return FALSE;
		$web=\Web::instance();
		$out=$web->request(self::URL_Recaptcha,[
			'method'=>'POST',
			'content'=>http_build_query([
				'secret'=>$secret,
				'response'=>$response,
				'remoteip'=>$fw->IP
			]),
		]);
		return isset($out['body']) &&
			($json=json_decode($out['body'],TRUE)) &&
			isset($json['success']) && $json['success'];
	}
214046
private function handleResponse($response)
    {
        if ($response instanceof PagedListResponse || $response instanceof GaxPagedListResponse) {
            $response = $response->getPage()->getResponseObject();
        }

        if ($response instanceof Message) {
            return $this->serializer->encodeMessage($response);
        }

        if ($response instanceof OperationResponse || $response instanceof GaxOperationResponse) {
            return $response;
        }

        if ($response instanceof ServerStream || $response instanceof GaxServerStream) {
            return $this->handleStream($response);
        }

        return null;
    }
338195
protected function getStatus($response)
    {
        if (isset($response['refunded']) && $response['refunded'] == true) {
            return new Status('refunded');
        }

        if (!isset($response['status']) && !isset($response['type'])) {
            return;
        }

        $status = isset($response['status']) ? $response['status'] : $response['type'];

        switch ($status) {
            case 'pending':
            case 'charge.pending':
                return new Status('pending');
            case 'success':
            case 'charge.success':
                return new Status('paid');
            case 'declined':
            case 'charge.declined':
                return new Status('failed');
            case 'deleted':
            case 'charge.deleted':
                return new Status('canceled');
            case 'expired':
            case 'charge.expired':
                return new Status('voided');
                break;
        }
    }
779336
protected function respond($response)
    {
        if (Arr::get($response, 'object') === 'list') {
            if (!empty($response['data'])) {
                foreach ($response['data'] as $responseItem) {
                    $success = Arr::get($responseItem, 'object', 'error') !== 'error';

                    $responses[] = $this->mapResponse($success, $responseItem);
                }

                return $responses;
            } else {
                $response = $response['data'];
            }
        }

        $success = Arr::get($response, 'object', 'error') !== 'error';

        return $this->mapResponse($success, $response);
    }
183668
protected function getPaymentStatus($response)
    {
        $lastPayment = Arr::last($response['payments']);

        // approved, in_process, pending, rejected, cancelled
        // on testing at least, payments may be empty
        return $lastPayment ? Arr::get($lastPayment, 'status', 'other') : 'no_payment';
    }
968238
private function whenSuccess($response, $method)
    {
        $this->makeSession($response, $method);
        return $this->result->setData([
            'success' => true,
            'payload' => [
                'redirect' => sprintf('%s%s', $this->baseUrl(), 'pagseguro/direct/success')
            ]
        ]);
    }
1159735
protected function isApprove($response){
        $result = false;

        if($response->getResponseCode() == CheckoutApi_Client_Constant::RESPONSE_CODE_APPROVED
            || $response->getResponseCode()== CheckoutApi_Client_Constant::RESPONSE_CODE_APPROVED_RISK ){
            $result = true;
        }

        return $result;
    }
1060405
protected function response($response) {
    // Check for HTTP response error codes.
    if ($this->client->error) {
      $this->onErrorResponse(
        $this->client->errorCode,
        $this->client->errorMessage,
        $response
      );
    }
    else {
      $this->onSuccessfulResponse($response);
    }
    return $response;
  }
120572
public function checkGitkitError($response) {
    if (isset($response['error'])) {
      $error = $response['error'];
      if (!isset($error['code'])) {
        throw new Gitkit_ServerException('null error code from Gitkit server');
      } else {
        $code = $error['code'];
        if (strpos($code, '4') === 0) {
          throw new Gitkit_ClientException($error['message']);
        } else {
          throw new Gitkit_ServerException($error['message']);
        }
      }
    } else {
      return $response;
    }
  }
827669
public function verify()
    {
        if (!$this->_config['enable']) {
            return true;
        }

        $controller = $this->_registry->getController();
        if ($controller->request->getData('g-recaptcha-response')) {
            $response = json_decode($this->apiCall());

            if (isset($response->success)) {
                return $response->success;
            }
        }

        return false;
    }