<?php

	class MyBoosterAdminAPI {

		protected $mainAPIUrl = "http://localhost/MyBooster/admin/API/";
		protected $baseAPIUrl = "http://localhost/MyBooster/admin/API/";
		//protected $mainAPIUrl = "http://localhost/admin/";
		//protected $baseAPIUrl = "http://localhost/admin/API/";

		//protected $baseAPIUrl = "http://35.154.98.204/blockbooster/adminAPI/";
		//protected $mainAPIUrl = "http://35.154.98.204/blockbooster/";
		//protected $mainAPIUrl = "http://localhost/blockbooster/adminAPI/";
		//protected $baseAPIUrl = "http://localhost/blockbooster/API/adminAPI/";


		public function __construct(){

		}

		protected function curlRequest($url,$dataString=''){

			$url = (empty($dataString['mainUrl']) ? $this->baseAPIUrl : $this->mainAPIUrl).$url;

			$data_string = http_build_query($dataString);
			$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);

		    $output['response'] = curl_exec($ch);
		    $output['status'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		    
		    return $output;
		}

		

		public function Member_List_API($data=array()){

			$apiName = 'API_Member_Profile_List.php';


			$params = $data;

			$curlResponse = $this->curlRequest($apiName,$params);
			// print_r($curlResponse);exit();
			if($curlResponse['status']==200){
				return json_decode($curlResponse['response'],true);
			}
			else{

				$result['status'] = 0;
				$result['curl_status'] = $curlResponse['status'];
				$result['message'] = "Error while calling API.";
				return $result;
			}
		}



		
		public function User_List_API($data=array()){

			$apiName = 'API_User_List.php';


			$params = $data;

			$curlResponse = $this->curlRequest($apiName,$params);
			// print_r($curlResponse);exit();
			if($curlResponse['status']==200){
				return json_decode($curlResponse['response'],true);
			}
			else{

				$result['status'] = 0;
				$result['curl_status'] = $curlResponse['status'];
				$result['message'] = "Error while calling API.";
				return $result;
			}
		}


	
	}
?>