0

API の REST 関数を GET プロトコルで呼び出したいのですが、restler のセキュリティ キーをポスト パラメータとして設定できませんでした。

例:

/index.php/myrestapi/method.json?name=テスト投稿フィールド: 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 に答える