/** * {@inheritDoc} */ public function call(RequestInterface $request) { /** * @var Response $response */ $response = $this->browser->submit($this->getEndpoint(), $request->getParameters()); if ($response->isSuccessful()) { return $response->getContent(); } else { return false; } }
/** * {@inheritDoc} * * @param RequestInterface $request Request instance * * @throws \RuntimeException On cURL error * * @return string $response The html of the temporary form */ public function call(RequestInterface $request) { $this->checkEndpoint(); $ch = curl_init(); // cURL options $options = array(CURLOPT_URL => $this->getEndpoint(), CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($request->getParameters())); curl_setopt_array($ch, $options); $response = curl_exec($ch); $curlErrorNumber = curl_errno($ch); $curlErrorMessage = curl_error($ch); $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (!in_array($responseCode, array(0, 200, 201, 204))) { throw new \RuntimeException('cUrl returns some errors (cURL errno ' . $curlErrorNumber . '): ' . $curlErrorMessage . ' (HTTP Code: ' . $responseCode . ')'); } curl_close($ch); return $response; }