2018-01-28 17:17:19 +00:00
|
|
|
<?php
|
2021-09-13 18:51:12 +00:00
|
|
|
|
2018-01-28 17:17:19 +00:00
|
|
|
/**
|
|
|
|
* The MIT License
|
|
|
|
* Copyright (c) 2007 Andy Smith
|
|
|
|
*/
|
2021-09-13 18:51:12 +00:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-01-28 17:17:19 +00:00
|
|
|
namespace Abraham\TwitterOAuth;
|
|
|
|
|
|
|
|
class Token
|
|
|
|
{
|
|
|
|
/** @var string */
|
|
|
|
public $key;
|
|
|
|
/** @var string */
|
|
|
|
public $secret;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $key The OAuth Token
|
|
|
|
* @param string $secret The OAuth Token Secret
|
|
|
|
*/
|
2021-09-13 18:51:12 +00:00
|
|
|
public function __construct(?string $key, ?string $secret)
|
2018-01-28 17:17:19 +00:00
|
|
|
{
|
|
|
|
$this->key = $key;
|
|
|
|
$this->secret = $secret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the basic string serialization of a token that a server
|
|
|
|
* would respond to request_token and access_token calls with
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2021-09-13 18:51:12 +00:00
|
|
|
public function __toString(): string
|
2018-01-28 17:17:19 +00:00
|
|
|
{
|
2021-09-13 18:51:12 +00:00
|
|
|
return sprintf(
|
|
|
|
'oauth_token=%s&oauth_token_secret=%s',
|
2018-01-28 17:17:19 +00:00
|
|
|
Util::urlencodeRfc3986($this->key),
|
|
|
|
Util::urlencodeRfc3986($this->secret)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|