Using REST_Controller Codeigniter API with key

Here is my code for my PHP application to access the CI Rest Library by Phil sturgeon. When I disable the api key it seems fine. This is the json result as follows:

[{"groupID":"1","listID":"1","groupTitle":"GroupA","groupName":"Group Name 1"}]

And when I try enabling the api key in rest library. I receive this

{"status":false,"error":"Unknown method."}

Trying also on my terminal:

I got this

CURL

[2012-07-03 14:11.42]  ~
[User4001.me] → curl -X POST -H "X-API-KEY: 221b368d7f5f597867f525971f28ff75" http://localhost/mailapi/index.php/api/group/id/1
{"status":false,"error":"Unknown method."}   

ON PHP test.php

$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => 'http://localhost/mailapi/index.php/api/group/id/1',
    CURLOPT_POSTFIELDS => 'X-API-KEY=221b368d7f5f597867f525971f28ff75'
));
$response = curl_exec($ch);

echo"<pre>";
print_r($response);
echo"</pre>";

Am I missing something?

Answers


Phils library by default looks for X-API-KEY as a header, not a post. The documentation clearly states you need to change the config file to accept post vars.


Need Your Help

MYSQL AUTO_INCREMENT in the event of both user register a account at the same time?

mysql

i am just wondering what happen if both user register a account at the same time.

Calculating AVERAGEIF in R by factor level

r excel

In Calculating percentiles by factor using ave() in r, I asked how to calculate percentiles within the ave() function. With that task finished, I'm faced with a more difficult task.