예제 #1
0
 protected static function setup_account($baseUrl, $apiKey = FALSE, $accountId = FALSE, $checkSSL = 2)
 {
     //Generic account setup program, prints out errors in the html if incomplete
     //Set the url
     self::$baseUrl = $baseUrl;
     self::$instruments = array();
     self::$checkSSL = $checkSSL;
     //Checking our login details
     if (strpos($baseUrl, 'https') !== FALSE || strpos($baseUrl, 'fxpractice') !== FALSE) {
         //Check that we have specified an API key
         if (!self::valid($apiKey, TRUE, 'Must provide API key for ' . $baseUrl . ' server.')) {
             return FALSE;
         }
         //Set the API key
         self::$apiKey = $apiKey;
         //Check that we have specified an accountId
         if (!self::valid($accountId)) {
             if (!self::valid($accounts = self::accounts(), TRUE, 'No valid accounts for API key.')) {
                 return FALSE;
             }
             self::$account = $accounts->accounts[0];
             //else if we passed an accountId
         } else {
             self::$account = self::account($accountId);
         }
     }
     //Completed
     return self::nav_account(TRUE);
 }