0
我想用GET協議調用api的rest函數,但是我沒有成功將restler的安全密鑰作爲post參數。Restler:在post參數中使用安全密鑰發出get請求
例如:
/index.php/myrestapi/method.json?name=test 交字段:陣列( '鑰匙'=> '的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;
}
有什麼問題?
在此先感謝您的幫助!
凱文
值得記住的是,如果您嘗試添加「POST」參數,那麼您正在執行POST請求,而不是GET。 – igorsantos07