pear HTTP_Request vs cURL,which one?

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
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

pear HTTP_Request vs cURL,which one?

Post by highjo »

hi guys
tring to make an API call by sendind a Request through http.honestly a prefere using the pear HTTP_Request and it seems to be not working.And finally i came back to do curl to mke things actually work.My question is it because i'm ot doing it well or it's not working yet.using php 5.2.5.
here is the code

Code: Select all

include_once('HTTP/Request.php');
//this is the conf file and in it we have an example.$password = "thepassword";
include_once("SMSAPI_conf.php");
$req = &new HTTP_Request("http://someaddress/http/auth");
    $req->setMethod(HTTP_RESQUEST_METHOD_POST);
    $req->addPostData('api_id',$api_id);
    $req->addPostData('user',$user);
    $req->addPostData('password', $password);
    $req->sendRequest();
    $response = $req->getResponseBody();
var_dump($response);
my qustionis should the address contains "?" at the end like http://someaddress/http/auth? or http://someaddress/http/auth/.
It is saying invalid api_pi stuff as error response.I 've noticed too that i'm hving a probleme on using global variables located in the include file.If i echo them i can see it so i thinking that something is wrong in my codes.As i sais with the curl it is working the the same include file.What do you think?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: pear HTTP_Request vs cURL,which one?

Post by onion2k »

I prefer Curl. It's nicer and it actually more likely to be available on the server in my experience. Lots of hosts don't make PEAR available, while very few switch Curl off.
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

Re: pear HTTP_Request vs cURL,which one?

Post by highjo »

thanks bro thought pear one is newer and simplier.Do you know any alternative available and much simplier than curl?
Post Reply