我想用GET协议调用我的api的rest函数,但我没有成功地将restler的安全密钥作为post参数。
例:
/index.php/myrestapi/method.json?name=test帖子字段 : 数组('键'=>'我的键')
$session = curl_init('<mydomainurl>/index.php/myrestapi/method.json?name=test');
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, array('key'=>'mykey');
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($session);
Myrestapi.php 函数:
protected function getMethod($name){
return $name;
}
怎么了?!
提前感谢您的帮助!
凯文
安全密钥也应该是 get 参数的一部分
<mydomainurl>/index.php/myrestapi/method.json?name=test&key=mykey
然后需要使用iAuthenticate来处理它。
有关更多详细信息,请参阅例如 restler 的受保护 API。