Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class TokenStorage
- {
- /**
- * Infusionsoft Token object
- *
- * @var object
- */
- private $token;
- /**
- * Path to save the token
- *
- * @var string
- */
- private $path = '/[path_to_project]/TokenStorage';
- /**
- * Name of the token file
- *
- * @var string
- */
- private $filename = 'token.dat';
- /**
- * Instantiate the storage object and initialize the token.
- */
- public function __construct()
- {
- $this->token = unserialize(file_get_contents($this->path.DIRECTORY_SEPARATOR.$this->filename));
- }
- /**
- * Return the token
- *
- * @return object
- */
- public function getToken()
- {
- return $this->token;
- }
- /**
- * Serialize and store the token
- *
- * @param object $token
- * @return void
- */
- public function saveToken($token)
- {
- file_put_contents($this->path.DIRECTORY_SEPARATOR.$this->filename, serialize($token));
- }
- }
Add Comment
Please, Sign In to add comment