0
我是這個問題的新手。我試圖創建一個搜索表單,它允許通過http api搜索數據庫並在網站上顯示結果。呼叫需要授權:使用http api進行搜索表單
$headers = array ('headers' => array(
'Authorization' => 'bearer' . $token ,
'Content-type' => 'application/json',
'Accept' => 'application/json'));
我的搜索形式如下:
<form method="GET" accept="application/json" action="https://example.xx/api/v1/products?page=1&size=5&direction=asc&search=value">
<input type="text" name="search" size="40" maxlength="256" value="" placeholder="testsearch">
<input type="submit" name="search_button" value="Search">
</form>
當我輸入內容的輸入字段,並點擊提交按鈕,瀏覽器顯示:
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
而在瀏覽器地址字段我看到:
https://example.xx/api/v1/products?search=testvalue&search_button=Search
顯然授權被忽略,URL顯示,我已經離開我的網站。
我一定使這項工作與行動=「somephp.php」? 我如何授權來自表單的電話並在網站上顯示回覆? 提示非常感謝。西奧