Last active
September 18, 2017 10:41
-
-
Save michaloo/c349b41ab7a37997a66d327f72124522 to your computer and use it in GitHub Desktop.
Hull Client + Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this is main theme functions.php file | |
// first require Hull_Client files, | |
// if you are using Composer following line enable autoload: | |
require "vendor/autoload.php"; | |
function hull_init_client() { | |
$current_user = wp_get_current_user(); | |
if ($current_user->ID) { | |
$hull = new Hull_Client(array( | |
'hull' => array( | |
'host' => 'org-url', | |
'appId' => 'platform-id', | |
'appSecret' => 'platform-secret' | |
) | |
)); | |
$userData = array( | |
'email' => $current_user->user_email, | |
'external_id' => $current_user->ID | |
); | |
?> | |
<script id="hull-js-sdk" | |
access-token="<?php echo $hull->userToken($userData) ?>" | |
org-url="<?php echo $hull->host ?>" | |
platform-id="<?php echo $hull->appId ?>" | |
src="https://js.hull.io/0.10.0/hull.js.gz" async></script> | |
<?php | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'hull_init_client' ); | |
Hey @lkraav - The Hull client doesn't generate a remote token api request - It generates a JWT, signed with the appSecret. No remote calls there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmmm. Does this cause every logged in pageview to generate a remote token API request? This does not sound sensible. Can the access token be cached?