/** * @param string $serviceUrl * @param string $method * @param null $headers * @param null $data * @param null $callback * @param string $errors * @param array $params * @return mixed */ protected function makeRequest($serviceUrl, $method = self::GET, $headers = null, $data = null, $callback = null, $errors = self::STRICT, array $params = []) { $timeout = 30; $errorModes = array(self::STRICT, self::GRACEFUL, self::IGNORE); $errorMode = $errors; if (!in_array($errorMode, $errorModes)) { throw new UnexpectedValueException('Possible values for errors argument are: ' . implode(", ", $errorModes)); } if ($callback == null) { $callback = array('self', 'defaultRespCallback'); } // echo "strpos: " . strpos('apikey', strtolower($serviceUrl)); // if (strpos(strtolower($serviceUrl), 'apikey') == false) { // echo "API key not found in: " . $serviceUrl; $params['apiKey'] = $this->apiKey; // } if (count($params) > 0) { $serviceUrl .= '?' . http_build_query($params); } // if ($callback == array('self', 'getPollURL')) { // unset($params['apiKey']); // } // use our own httpRequest function if HttpRequest class is not available. $r = NetworkUtils::httpRequest($serviceUrl, $headers, $method, $data); // try { return call_user_func($callback, $r); // } catch(Exception $e) { // return self::withErrorHandling($r, null, $errorMode); // } }