这是我的FlightController.php文件
public function data(){
// URL
$apiURL = 'http://stageapi.ksofttechnology.com/API/FLIGHT/';
// POST Data
$postInput = [
"TYPE"=> "AIR",
"NAME"=> "GET_FLIGHT",
"STR"=> [
"AUTH_TOKEN"=> "***********************",
"SESSION_ID"=> "",
"TRIP"=> "1",
"SECTOR"=> "D",
"SRC"=> "DEL",
"DES"=> "BOM",
"DEP_DATE"=> "2022-12-10",
"RET_DATE"=> "",
"ADT"=> "1",
"CHD"=> "0",
"INF"=> "0",
"PC"=> "",
"PF"=> "",
"HS"=> "D",
],
];
// Headers
$headers = [
];
$response = Http::withHeaders($headers)->post($apiURL, $postInput);
$statusCode = $response->status();
$responseBody = json_decode($response->getBody(), true);
dd($responseBody); // body response
}
工艺文件:
Route::post('/flightdata', [FlightController::class,'data']);
错误:500内部服务器错误
1条答案
按热度按时间2nbm6dog1#
你的代码对我来说是有效的,所以它一定是一些小错误,比如你的控制器里没有
use Illuminate\Support\Facades\Http;
。请确保在
.env
文件中设置APP_DEBUG=true
,并使用php artisan config:clear
清除配置缓存,然后您应该能够看到错误消息。