api login rest with php not working

Extending the system, interesting uses and API twiddling.
Post Reply
restassured
Posts: 2
Joined: Tue May 08, 2012 9:46 am

api login rest with php not working

Post by restassured » Tue May 08, 2012 9:56 am

Hi,

I'm trying to use the curl function in php to send a rest post to login, the basic code is shown below. This would be the right method for send REST requests. However it returns no response, I wondered if anyone has had success with this or can see what I might be doing wrong? thanks

$username="myusername";
$password="mypassword";
$url="https://api.alertme.com/login/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

restassured
Posts: 2
Joined: Tue May 08, 2012 9:46 am

Re: api login rest with php not working

Post by restassured » Tue May 08, 2012 10:21 am

I do get a response, but obviously looking for permission -

Forbidden

You don't have permission to access /login/ on this server.
Apache Server at api.alertme.com Port 443

User avatar
roobarb!
Site Admin
Posts: 221
Joined: Mon Nov 21, 2011 4:56 pm
Location: Manchester, UK
Contact:

api login rest with php not working

Post by roobarb! » Tue May 08, 2012 1:42 pm

I think you need a bit more in the way of authentication going on in there. I've not looked at the guts of using the API in quite a while now, but I'm not sure if a https curl request is enough?

There were a number of good PHP example scripts kicking around at one point, which should show you exactly how it works. Have a google, hopefully they'll still be available somewhere.
Alerty - control your AlertMe system with my third-party app for iPhone and iPod Touch. Available on iTunes!

Post Reply