开发者

HTTP_Request::setPostFields is an undefined method

开发者 https://www.devze.com 2023-01-06 12:07 出处:网络
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开发者_如何学Go to work at all, but now it seems happy with everything

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开发者_如何学Go 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!)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消