这是我的 PHP 应用程序访问由 Phil sturgeon 编写的 CI Rest 库的代码。当我禁用 api 密钥时,它似乎很好。这是json结果如下:
[{"groupID":"1","listID":"1","groupTitle":"GroupA","groupName":"Group Name 1"}]
当我尝试在 rest 库中启用 api 密钥时。我收到这个
{"status":false,"error":"Unknown method."}
也在我的终端上尝试:
我懂了
卷曲
[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."}
关于 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>";
我错过了什么吗?