Одной из альтернатив будет использование функций потока PHP вместо curl
http://www.php.net/manual/en/ref.stream.php
Ваш код будет выглядеть примерно так:
$url = "http://some-restful-client/";
$params = array('http' => array(
'method' => "GET",
));
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp)
{
throw new Error("Problem with ".$url);
}
$response = @stream_get_contents($fp);
if ($response === false)
{
throw new Error("Problem reading data from ".$url);
}
echo $response //this is the contents of your request;
Вам нужно использовать PHP 4> = 4.3.0 или PHP 5 tho
UPDATE:
Я завернул это в краткий урок для вас. Чтобы использовать это, сделайте что-то вроде следующего
$hr = new HTTPRequest("http://someurl.com", "GET");
try
{
$data = $hr->send();
echo $data;
}
catch (Exception $e)
{
echo $e->getMessage();
}
Вот код для класса. Вы также можете передать данные в 3-й и 4-й параметры конструктора, чтобы соответственно установить данные и заголовки записей. Обратите внимание, что данные поста должны быть строкой, а не массивом, заголовки должны быть массивом с ключами, являющимися именем заголовка
Надеюсь, это поможет !!!
<?php
/**
* HTTPRequest Class
*
* Performs an HTTP request
* @author Adam Phillips
*/
class HTTPRequest
{
public $url;
public $method;
public $postData;
public $headers;
public $data = "";
public function __construct($url=null, $method=null, $postdata=null, $headers=null)
{
$this->url = $url;
$this->method = $method;
$this->postData = $postdata;
$this->headers = $headers;
}
public function send()
{
$params = array('http' => array(
'method' => $this->method,
'content' => $this->data
));
$headers = "";
if ($this->headers)
{
foreach ($this->headers as $hkey=>$hval)
{
$headers .= $hkey.": ".$hval."\n";
}
}
$params['http']['header'] = $headers;
$ctx = stream_context_create($params);
$fp = @fopen($this->url, 'rb', false, $ctx);
if (!$fp)
{
throw new Exception("Problem with ".$this->url);
}
$response = @stream_get_contents($fp);
if ($response === false)
{
throw new Exception("Problem reading data from ".$this->url);
}
return $response;
}
}
?>