Page 1 of 1

Ahhh! no more cURL, what do I do?

Posted: Wed Aug 26, 2009 10:50 pm
by woahtuff
My hosting provider no longer offers curl support and that's all I've used before for the functionality I've needed.

In particular, I'm looking for an alternative to curl to make this function work...

private function GetQueryResponse($requestUrl, $postString) {
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);

return $response;
}

I've been looking at fopen and file_get_contents from what info I could find on the board here, but I'm in a time crunch and can't seem to wrap my head around how i might make an alternative function. Any help would be greatly appreciated.

Re: Ahhh! no more cURL, what do I do?

Posted: Thu Aug 27, 2009 1:23 am
by JAB Creations
I'm totally stealing this off of a search on Google so I'll quote it...
There's the HTTP_Request PEAR library; you could use system() to call a command-line tool such as "/usr/bin/wget" or "/usr/bin/GET";
Beyond that I'm not sure. You really don't want to depend too heavily on cURL for mission-critical stuff. What would happen if the page you're getting information from changes?

Re: Ahhh! no more cURL, what do I do?

Posted: Thu Aug 27, 2009 2:37 am
by woahtuff
Well, it makes the request to an api that isn't going anywhere, so using curl hadn't been a prob up until now. I'll check out HTTP_Request PEAR library though, thanks.

Re: Ahhh! no more cURL, what do I do?

Posted: Thu Aug 27, 2009 5:52 am
by Eran
You really don't want to depend too heavily on cURL for mission-critical stuff
Where did you get that from?
For anything remotely complicated, definitely use cURL to generate your requests.

If you are using PHP5+ you can use the built in HttpRequest class - http://www.php.net/manual/en/class.httprequest.php
But if you need to generate complex requests, cURL is your only option

Re: Ahhh! no more cURL, what do I do?

Posted: Thu Aug 27, 2009 10:20 am
by John Cartwright
pytrin wrote:
You really don't want to depend too heavily on cURL for mission-critical stuff
Where did you get that from?
For anything remotely complicated, definitely use cURL to generate your requests.

If you are using PHP5+ you can use the built in HttpRequest class - http://www.php.net/manual/en/class.httprequest.php
But if you need to generate complex requests, cURL is your only option
You can always communicate through fsockopen() and send the headers yourself :)

Re: Ahhh! no more cURL, what do I do?

Posted: Thu Aug 27, 2009 10:25 am
by jackpf
I'd get a different host personally.

Re: Ahhh! no more cURL, what do I do?

Posted: Thu Aug 27, 2009 11:19 am
by Eran
You can always communicate through fsockopen() and send the headers yourself
Right :)
forgot about good old sockets..