0

我想用 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;
}

怎么了?!

在此先感谢您的帮助!

凯文

4

1 回答 1

0

安全密钥也应该是 get 参数的一部分

<mydomainurl>/index.php/myrestapi/method.json?name=test&key=mykey

然后需要使用 iAuthenticate 来处理。

有关更多详细信息,请参见restler 的受保护API。

于 2012-05-29T13:53:05.643 回答