public static function APIKey($apiKey = null) { if (isset($apiKey)) { self::$apiKey = $apiKey; } else { return self::$apiKey; } }
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); }