tags:

views:

435

answers:

1

Hi,

I am using curl and i want to post through posterous api. I am using this method posterous.com/api/newpost

My code is

$url="userid"
$posturl = "posterous.com/api/newpost";
$session = curl_init($posturl);
$postVars = array(

"site_id" => $url,

"body"=>$message     

);

curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $postVars);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
$obj = json_decode($response,true);
curl_close($session);

But I am getting this error

<rsp stat="fail">
 <err code="3001" msg="Invalid Posterous email or password" />
</rsp>

Please guide me on this

Thanks

+1  A: 

Well you don't actually seem to be sending an email address or password, so I guess that's the problem.

All calls require user authentication which is done by basic HTTP authentication with a user's Posterous email address and password.

You can do it like this:

$user = '[email protected]';
$password = 'foobar';

curl_setopt($session, CURLOPT_USERPWD, $user . ":" . $password);
Greg
Hi,But how can i send this details there is no such mention in the api method ?
HI, But after providing the authentication details same error is still occuring
Why dont you simply send an normal email to [email protected].. would be simply, doesnt it?
DaNieL
It actually IS in their API docs:All calls require user authentication which is done by basic HTTP authentication with a user's Posterous email address and password.
TML