Answer the question
In order to leave comments, you need to log in
Algorithm for interacting with third-party services through models or packages?
A laravel application accepts a string in a GET/POST request. Then it searches for information on this line by accessing third-party sites through the API (an example of such an application: aviasales.ru and similar services).
The number of sites that you need to access is not known in advance, the API is different for everyone. The question is how in laravel to organize the storage of classes for interacting with the API of each site.
I would like to be able to access sites in the controller as follows:
$keyword = Input::get('keyword');
$results = array();
$APIs = someFunctionToGetAPIs();
foreach ($APIs as $API) {
$results[] = $API->get($keyword);
}
Answer the question
In order to leave comments, you need to log in
Usual factory, you take out apishki in a config
foreach (Config::get('api.list') as $apiName) {
$results[$apiName] = Api::create($apiName)->get($keyword);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question