Guest User

Untitled

a guest
Jan 21st, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. class TokenStorage
  4. {
  5. /**
  6. * Infusionsoft Token object
  7. *
  8. * @var object
  9. */
  10. private $token;
  11.  
  12. /**
  13. * Path to save the token
  14. *
  15. * @var string
  16. */
  17. private $path = '/[path_to_project]/TokenStorage';
  18.  
  19. /**
  20. * Name of the token file
  21. *
  22. * @var string
  23. */
  24. private $filename = 'token.dat';
  25.  
  26.  
  27. /**
  28. * Instantiate the storage object and initialize the token.
  29. */
  30. public function __construct()
  31. {
  32. $this->token = unserialize(file_get_contents($this->path.DIRECTORY_SEPARATOR.$this->filename));
  33. }
  34.  
  35. /**
  36. * Return the token
  37. *
  38. * @return object
  39. */
  40. public function getToken()
  41. {
  42. return $this->token;
  43. }
  44.  
  45. /**
  46. * Serialize and store the token
  47. *
  48. * @param object $token
  49. * @return void
  50. */
  51. public function saveToken($token)
  52. {
  53. file_put_contents($this->path.DIRECTORY_SEPARATOR.$this->filename, serialize($token));
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment