Пример #1
0
 /**
  * @return string Return base url of user's account.
  */
 public static function getBaseUrl()
 {
     return User::getInstance()->getApiUrl();
 }
Пример #2
0
 public function testCanGetUserAppUrl()
 {
     $user = User::getInstance();
     echo $user->getApiUrl();
 }
Пример #3
0
 /**
  * @param $json
  */
 public static function injectOAuthToken($json)
 {
     User::getInstance()->oAuthToken = new Authorization\OAuthToken($json);
 }
Пример #4
0
 /**
  * Get the authorization header string.
  * @throws \Exception
  * @return string
  */
 private function getAuthorizationHeader()
 {
     // Get configuration.
     $config = Config::getInstance();
     $user = User::getInstance();
     // Return basic http string
     if (AuthType::BASIC_HTTP == $config->authenticationType) {
         $userpass = "******";
         $string = base64_encode($userpass);
         return "Authorization: Basic {$string}";
     }
     // Return oauth bearer
     if (AuthType::OAUTH == $config->authenticationType) {
         if (!isset($user->oAuthToken->access_token)) {
             throw new \Exception('An OAuth token Must be injected into the library!');
         }
         return "Authorization: Bearer {$user->oAuthToken->access_token}";
     }
     return false;
 }