I am new to Laravel and want to search via YouTube Data API, but when I click the search button it routes me to the login page. Cannot see the result unless logging in.
The controller search function:
public function search(Request $request)
{
$keyword = $request->keyword;
$params = [
'q' => $keyword,
'type' => 'video',
'part' => 'id, snippet',
'maxResults' => 5,
'order' => $request->orderby,
'videoDuration' => $request->duration,
'location' => $request->latitude ? $request->latitude.', '. $request->longitude : '40.936714, 29.012689',
'locationRadius' => $request->radius ? $request->radius.'km' : '100km'
];
$searchResults = Youtube::searchAdvanced($params, true);
$channelIds= array();
$channels= array();
foreach($searchResults["results"] as $el){
array_push($channelIds,$el->snippet->channelId);
}
foreach($channelIds as $id){
$channel = Youtube::getChannelById($id);
array_push($channels,$channel);
}
$channels=array_unique($channels);
return view('welcome2', compact('searchResults', 'keyword', 'channels'));
}
After clicking search, the URL turns into localhost:8000/login
.
When looking at the web.php
, I cannot see /login
route. Do not understand where is the problem:
Route::name('welcome')->get('/', 'PresentationController@index');
Route::name('youtube.search')->get('/youtube/search','YoutubeController@search');
Auth::routes();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…