Does entering the same path 'http://localhost/api-test/1/0.2/users/ auth.xml' from a browser give you a different error. I think you are right in thinking this is a routing problem, but I would assume it is a routing problem higher up the chain with your environment not with cake. Meaning it would appear your http://localhost/ is pointing to a cake deployment, and that you do not have a proper alias setup in (I'll assume apache) for your 'api-test' to point to your specific cake deployment. So the server is hitting your root cake folder and trying to process the request and parsing for the api-test as a controller instead of an app folder.
What is your web environment (server, default or root directory etc.)? How many different cakephp apps are being hosted from your localhost? what are their aliases etc. On Jun 26, 1:14 pm, bsuichies <[email protected]> wrote: > Situation: I'm building an API with cakePHP which holds user-accounts. > I'd like to have multiple websites authenticating using this API by > sending a post-request to the api and receiving the proper xml with > user-info. > > To accomodate routing, I've added the following rule in routes.php. > > Router::connect('/:channel/:version/:controller/:action/*', > array('prefix' => 'api', 'api' => true), > array('channel' => '[0-9]+'), > array('version'=>'[0-9]+\.[0-9]+')); > > I've also created a form that holds all the necessary information > (username + password) and tested this. This works. However, I'd like > to use cURL to form a post-request & receive the information. For > this, I created the code below. > > $api_url = 'http://localhost/api-test/1/0.2/users/auth.xml'; > $api_token = 'xxxxxxxxxxxxxx'; > $url = $api_url.'?token='.$api_token; > $data = array('user' => $user, 'password' => $password); > $ch = curl_init($url); > curl_setopt ($ch, CURLOPT_POST, true); > curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); > curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); > curl_setopt ($ch, CURLOPT_HEADER, false); > curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); > $result = curl_exec($ch); > $error = curl_error($ch); > $info = curl_getinfo($ch); > curl_close($ch); > > This strangely doesn't work. The connection is working, but the > routing appears to be failing, as the controller 'api-test' is called > (which doesn't exist, this is my main-folder of my test-application) > instead of the user-controller. I'm sure I must be missing something, > but I can't figure out what that is.. I'm sure it's something between > cURL and cakePHP, as a normal form works as intended. Anyone got any > advice? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
