$data = 'data[User][token]=87f77a583929c700119878128dc108bd62ca7772';
$data .= '&data[Ride][start_address]=Osijek, Croatia';
$data .= '&data[Ride][end_address]=Pula, Croatia';
$ch = curl_init('http://domain.com/controller/action.json');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$head = curl_exec($ch);
print_r($head);
curl_close($ch);
Then, in some controller you go:
function action() {
if ($this->RequetsHandler->ext === 'json') {
//ext could be an xml also, and here you do stuff with post data
}
}
Router::parseExtensions('json');
hope this example helps you.
On Mon, Oct 22, 2012 at 12:42 PM, Zap <dixiemeart@gmail.com> wrote:
Hi everyone.The webfront of my website is ready, but I want to give access to core functions via an API.
Thing is, for public data (like juse rinfo and such), I already used request handler to have json or XML special views, so I guess that's ok.But, I was wondering how to achieve POST action ?Indeed, I want some actions to need authentification :Posts -> add
Posts -> deletePlus, for the "add" action, I'm wondering how is the data sent ? My posts allow 300 characters, bu I Guess it isn't in the url parameters ? Or is it ?
I'm wonering about the routing also, as some actions are under User -> view and new one I want to emplement under Posts - >add etc.
Is it possible to regroup this as /api/post/add or api/users/view/ ?Thanks a lot but the REST doc wasn't really helpfull to me.Thanks !--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
Ivan Rimac
mail: ivnrmc@gmail.com
tel: +385 95 555 99 66
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment