Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require $_SERVER["DOCUMENT_ROOT"]."/db_config.php";
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- //Local
- require_once '../vendor/autoload.php';
- // Prod
- //require_once '/var/www/tribeCentral/vendor/autoload.php';
- class isApi {
- public $infusionsoft;
- public function __construct() {
- echo "hit 1";
- $this->infusionsoft = new \Infusionsoft\Infusionsoft(array(
- 'clientId' => CLIENT_ID,
- 'clientSecret' => CLIENT_SECRET,
- 'redirectUri' => 'https://example.com/',
- ));
- $this->refreshToken();
- }
- public function refreshToken() {
- echo "hit 2";
- $tokenData = $this->retrieveToken();
- $this->infusionsoft->setToken($tokenData);
- }
- public function retrieveToken(){
- echo "hit 3";
- $hostname = PROD_HOSTNAME;
- $username = USERNAME;
- $password = PASSWORD;
- $database = "tmf_ca";
- $conn = new mysqli($hostname, $username, $password, $database);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT currSerializedToken FROM infusionsoftToken";
- $result = $conn->query($sql);
- $serializedToken = null;
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $serializedToken = $row["currSerializedToken"];
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- echo $serializedToken . "<br/>";
- echo base64_decode($serializedToken) . "<br>";
- print_r(unserialize(base64_decode($serializedToken)));
- return unserialize(base64_decode($serializedToken));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement