Ahhh! no more cURL, what do I do?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
woahtuff
Forum Newbie
Posts: 4
Joined: Wed Aug 26, 2009 10:36 pm

Ahhh! no more cURL, what do I do?

Post 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.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

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

Post 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?
woahtuff
Forum Newbie
Posts: 4
Joined: Wed Aug 26, 2009 10:36 pm

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

Post 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.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

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

Post 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 :)
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post by jackpf »

I'd get a different host personally.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

Post by Eran »

You can always communicate through fsockopen() and send the headers yourself
Right :)
forgot about good old sockets..
Post Reply