I want to use 3rd party API service in my laravel web application. I know how to connect to the 3rd API service. So i wrote my code in controller. actually i don't want to make lengthy code in controller class.
I want to build up separate class for this . Eg : "VideoAPI" and i want to put all my API calling in there .after that i want to call them to my controller . is that best practice if , NO, please advise me .
Please suggest me your solution .
here is my controller code
...
....
public function getAllVideos()
{
$client = new Client();
$token = "eyJhbGciOisImlzcyI6Imh0dHBzOi8vZHludHViZS5jb20iLCJhdWQiOiJNYW5hZ2UifQ.uiCkRLmKyigO282US3VOhZjqyg6P-4F5MH8snRpF2uU";
$query = [
'page' => 1,
'size' => 100,
'sort' => 'name:-1',
];
$headers = [
'Authorization' => 'Bearer ' . $token,
];
$uri = "https://api.videomummy.com/v1/projects";
$response = $client->request('GET', $uri, [
'headers' => $headers,
'query'=> $query
]);
dd($response->getBody()->getContents());
}