這是我的控制器代碼:
public function tournaments() {
$data = 0;
$response = Http::withHeaders(
[
'x-rapidapi-host'=> 'uxxxx',
'x-rapidapi-key'=> 'asdfasdfas',
]
)->get('https://unibet.p.rapidapi.com/competitions-by-sport/football');
return $response;
}
并收到回應訊息: {"message":"Missing required parameters"}
如何向這些代碼添加引數?例如:params: {sport: 'football'},
也許有人可以分享一個關于如何使用 API LARAVEL 的教程視頻?
uj5u.com熱心網友回復:
如果您在談論查詢引數,那就是您正在尋找的內容:https ://laravel.com/docs/8.x/http-client#get-request-query-parameters
發出 GET 請求時,您可以將查詢字串直接附加到 URL 或將鍵/值對陣列作為第二個引數傳遞給 get 方法
這是它的外觀示例:
public function tournaments() {
$data = 0;
$response = Http::withHeaders(
[
'x-rapidapi-host'=> 'uxxxx',
'x-rapidapi-key'=> 'asdfasdfas',
]
)->get('https://unibet.p.rapidapi.com/competitions-by-sport', [
'sport' => 'football'
]);
return $response;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/411072.html
標籤:
上一篇:計算單詞中的音節數,但以“es”、“ed”結尾的單詞不計為音節
下一篇:查找觸發事件的模型方法
