Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?php
  2. require $_SERVER["DOCUMENT_ROOT"]."/db_config.php";
  3.  
  4. error_reporting(E_ALL);
  5. ini_set('display_errors', 1);
  6.  
  7. //Local
  8. require_once '../vendor/autoload.php';
  9.  
  10.  
  11. // Prod
  12. //require_once '/var/www/tribeCentral/vendor/autoload.php';
  13.  
  14. class isApi {
  15. public $infusionsoft;
  16. public function __construct() {
  17. echo "hit 1";
  18. $this->infusionsoft = new \Infusionsoft\Infusionsoft(array(
  19. 'clientId' => CLIENT_ID,
  20. 'clientSecret' => CLIENT_SECRET,
  21. 'redirectUri' => 'https://example.com/',
  22. ));
  23. $this->refreshToken();
  24. }
  25.  
  26. public function refreshToken() {
  27. echo "hit 2";
  28. $tokenData = $this->retrieveToken();
  29. $this->infusionsoft->setToken($tokenData);
  30. }
  31.  
  32. public function retrieveToken(){
  33. echo "hit 3";
  34. $hostname = PROD_HOSTNAME;
  35. $username = USERNAME;
  36. $password = PASSWORD;
  37. $database = "tmf_ca";
  38.  
  39. $conn = new mysqli($hostname, $username, $password, $database);
  40. if ($conn->connect_error) {
  41. die("Connection failed: " . $conn->connect_error);
  42. }
  43. $sql = "SELECT currSerializedToken FROM infusionsoftToken";
  44. $result = $conn->query($sql);
  45.  
  46. $serializedToken = null;
  47. if ($result->num_rows > 0) {
  48. // output data of each row
  49. while($row = $result->fetch_assoc()) {
  50. $serializedToken = $row["currSerializedToken"];
  51. }
  52. } else {
  53. echo "0 results";
  54. }
  55. $conn->close();
  56. echo $serializedToken . "<br/>";
  57. echo base64_decode($serializedToken) . "<br>";
  58. print_r(unserialize(base64_decode($serializedToken)));
  59.  
  60. return unserialize(base64_decode($serializedToken));
  61. }
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement