public static function APIURL($apiURL = null) { if (isset($apiURL)) { self::$apiURL = $apiURL; } else { // default API URL if (!isset(self::$apiURL)) { self::$apiURL = 'https://apps.fundamerica.com'; } return self::$apiURL . '/api/'; } }
private function call($curlopts = null) { if (!isset(static::$objectName)) { throw new Exception('No object name provided.'); } $ch = curl_init(); $url = FundAmerica::apiURL() . static::$objectName; $user = FundAmerica::apiKey() . ':'; if (isset($curlopts['id'])) { $url = $url . '/' . $curlopts['id']; unset($curlopts['id']); } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, $user); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if (isset($curlopts)) { foreach ($curlopts as $key => $value) { curl_setopt($ch, $key, $value); } } $response = curl_exec($ch); curl_close($ch); return json_decode($response, true); }