<?php

class API_Config{

   public $base_URL;

   

  function __construct() {

      //$this->base_URL = "http://localhost/admin/API/";
      $this->base_URL = "http://localhost/MyBooster/admin/API/";

   }

   
   public function call_API($apiName, $params){

		$url = $this->base_URL . $apiName;
		$request =json_encode($params);
		//echo $request;
		$ch = curl_init();
		curl_setopt( $ch, CURLOPT_URL, $url);
		curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt( $ch, CURLOPT_VERBOSE, true );
		curl_setopt( $ch, CURLOPT_ENCODING, '' );
		curl_setopt( $ch, CURLOPT_CUSTOMREQUEST,'POST');
		curl_setopt( $ch, CURLOPT_POSTFIELDS, $request);
		curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
		   'Content-Type: application/json'
		) );

		$response = curl_exec($ch);
		curl_close($ch);
		return $response;

   }


   
     public function call_API2($url,$dataString=''){

			$url = $this->base_URL . $url;
			$data_string = http_build_query($dataString);
			//print_r($data_string);
			$ch = curl_init($url);
		    curl_setopt($ch, CURLOPT_HEADER, 0);
		    curl_setopt($ch, CURLOPT_POST, 1);
		    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
		    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
		    curl_setopt($ch, CURLOPT_VERBOSE, 0);
		    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $response = curl_exec($ch);
			curl_close($ch);
			return $response;
		}


}









?>