views:

20

answers:

1

Hey, I've been battling with PHP all morning and it's now really starting to bug me!

I've had a hard time getting HTTP_Request to work at all, but now it seems happy with everything but setPostFields() which it claims to be undefined...

Here's my code - I'm a new PHP coder, so be gentle on my (non-existant/terrible) coding style.

require_once "HTTP/Request.php";

$url = "http://posterous.com/api/readposts";
$user = "******";
$pass = "******";

$request = new HTTP_Request($url);
$request->setMethod(HTTP_REQUEST_METHOD_POST);
$request->setPostFields(array('user' => $user, 'pass' => $pass));
try {
    $sring= $request->send()->getBody();
} catch (HTTP_Exception $ex) {
    echo $ex;
}

After that it's all xml (simples!)

A: 

I am assuming you are using this pear lib http://pear.php.net/package/HTTP_Request/docs/1.4.4/HTTP_Request/HTTP_Request.html ?

It does not seem to have that method. You might want to give this a try instead: http://www.php.net/manual/en/class.httprequest.php