diff --git a/Controller/SubsciberController.php b/Controller/SubsciberController.php index 682dcdadd2dbd56be592f24162edb05157c52c71..2b408d8b3db8a55c1c8843916ef5d7f8155cbba9 100644 --- a/Controller/SubsciberController.php +++ b/Controller/SubsciberController.php @@ -7,6 +7,7 @@ use Lib\Enums\Request\HttpStatus; use Lib\Interfaces\Routing\IRequest; use Lib\Interfaces\Routing\IResponse; use Model\Relations\Subscription; +use Lib\Service\Api\FetchAPI; class SubsciberController { static function setStatus(IRequest $req, IResponse $res) { @@ -140,20 +141,17 @@ class SubsciberController { } static function fetchSubscriptions(int $user_id,$db){ - $host = getenv("REST_HOST"); + $fetcher = new FetchAPI(getenv("REST_HOST")); + $param = [ + "page"=>1, + "limit"=>10 + ]; $rest_key = getenv("REST_KEY"); - $ch = curl_init("$host/singers?page=1&limit=10"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt( $ch , CURLOPT_RETURNTRANSFER, true); - curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER, false); - curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST, false); - curl_setopt( $ch , CURLOPT_TIMEOUT, 10000); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - "X-API-KEY: $rest_key" - )); - - $output = curl_exec($ch); - curl_close($ch); + $headers = [ + "X-API-KEY"=> $rest_key + ]; + $output = $fetcher->get("/singers",$param,$headers); + if(!$output){ return false; }