Page 1 of 1

pear HTTP_Request vs cURL,which one?

Posted: Wed Apr 30, 2008 6:03 am
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?

Re: pear HTTP_Request vs cURL,which one?

Posted: Wed Apr 30, 2008 6:24 am
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.

Re: pear HTTP_Request vs cURL,which one?

Posted: Wed Apr 30, 2008 6:34 am
by highjo
thanks bro thought pear one is newer and simplier.Do you know any alternative available and much simplier than curl?