token() 공개 메소드

Get or set a token
public token ( $token, $value = null ) : string
리턴 string
예제 #1
0
 /**
  * If the user is connected, then return the access_token and access_token_secret
  * if the provider api use oauth
  *
  * <code>
  * array(
  *   'access_token' => '',
  *   'access_token_secret' => '',
  *   'refresh_token' => '',
  *   'expires_in' => '',
  *   'expires_at' => '',
  * )
  * </code>
  * @return array
  */
 public function getAccessToken()
 {
     if (!$this->adapter->isUserConnected()) {
         Hybrid_Logger::error("User not connected to the provider.");
         throw new Exception("User not connected to the provider.", 7);
     }
     return array("access_token" => $this->adapter->token("access_token"), "access_token_secret" => $this->adapter->token("access_token_secret"), "refresh_token" => $this->adapter->token("refresh_token"), "expires_in" => $this->adapter->token("expires_in"), "expires_at" => $this->adapter->token("expires_at"));
 }
예제 #2
0
	/**
	 * If the user is connected, then return the access_token and access_token_secret
	 * if the provider api use oauth
	 *
	 * <code>
	 * array(
	 *   'access_token' => '',
	 *   'access_token_secret' => '',
	 *   'refresh_token' => '',
	 *   'expires_in' => '',
	 *   'expires_at' => '',
	 * )
	 * </code>
	 * @return array
	 */
	public function getAccessToken() {
		if (!$this->adapter->isUserConnected()) {
			Hybrid_Logger::error("User not connected to the provider.");
			throw new Exception("User not connected to the provider.", 7);
		}

		return array(
			"access_token" => $this->adapter->token("access_token"), // OAuth access token
			"access_token_secret" => $this->adapter->token("access_token_secret"), // OAuth access token secret
			"refresh_token" => $this->adapter->token("refresh_token"), // OAuth refresh token
			"expires_in" => $this->adapter->token("expires_in"), // OPTIONAL. The duration in seconds of the access token lifetime
			"expires_at" => $this->adapter->token("expires_at"), // OPTIONAL. Timestamp when the access_token expire. if not provided by the social api, then it should be calculated: expires_at = now + expires_in
		);
	}