{"id":3128,"date":"2014-03-16T22:55:55","date_gmt":"2014-03-16T22:55:55","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/16\/using-rest_controller-codeigniter-api-with-key-collection-of-common-programming-errors-2\/"},"modified":"2014-03-16T22:55:55","modified_gmt":"2014-03-16T22:55:55","slug":"using-rest_controller-codeigniter-api-with-key-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/16\/using-rest_controller-codeigniter-api-with-key-collection-of-common-programming-errors-2\/","title":{"rendered":"Using REST_Controller Codeigniter API with key-Collection of common programming errors"},"content":{"rendered":"<p>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:<\/p>\n<pre><code>[{\"groupID\":\"1\",\"listID\":\"1\",\"groupTitle\":\"GroupA\",\"groupName\":\"Group Name 1\"}]\n<\/code><\/pre>\n<p>And when I try enabling the api key in rest library. I receive this<\/p>\n<pre><code>{\"status\":false,\"error\":\"Unknown method.\"}\n<\/code><\/pre>\n<p>Trying also on my terminal:<\/p>\n<p>I got this<\/p>\n<p><strong>CURL<\/strong><\/p>\n<pre><code>[2012-07-03 14:11.42]  ~\n[User4001.me] ? curl -X POST -H \"X-API-KEY: 221b368d7f5f597867f525971f28ff75\" http:\/\/localhost\/mailapi\/index.php\/api\/group\/id\/1\n{\"status\":false,\"error\":\"Unknown method.\"}   \n<\/code><\/pre>\n<p><strong>ON PHP<\/strong><br \/>\ntest.php<\/p>\n<pre><code>$ch = curl_init();\ncurl_setopt_array($ch, array(\n    CURLOPT_RETURNTRANSFER =&gt; true,\n    CURLOPT_URL =&gt; 'http:\/\/localhost\/mailapi\/index.php\/api\/group\/id\/1',\n    CURLOPT_POSTFIELDS =&gt; 'X-API-KEY=221b368d7f5f597867f525971f28ff75'\n));\n$response = curl_exec($ch);\n\necho\"<\/code><\/pre>\n<pre><code>\";\nprint_r($response);\necho\"<\/code><\/pre>\n<pre>\";\n<\/pre>\n<p><code>Am I missing something?<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: [{&#8220;groupID&#8221;:&#8221;1&#8243;,&#8221;listID&#8221;:&#8221;1&#8243;,&#8221;groupTitle&#8221;:&#8221;GroupA&#8221;,&#8221;groupName&#8221;:&#8221;Group Name 1&#8243;}] And when I try enabling the api key in rest library. I receive this {&#8220;status&#8221;:false,&#8221;error&#8221;:&#8221;Unknown method.&#8221;} Trying also on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3128","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3128"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3128\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}