我想用 GET 协议调用我的 api 的 rest 函数,但我没有成功将 restler 的安全密钥作为 post 参数。
例子:
/index.php/myrestapi/method.json?name=test post field : Array('key'=>'mykey')
$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;
}
怎么了?!
在此先感谢您的帮助!
凯文