Skip to content

Commit

Permalink
updated heroku.md, cleaned up code, added comments
Browse files Browse the repository at this point in the history
finalizing
  • Loading branch information
atarisafari committed Oct 11, 2019
1 parent dbd4f3d commit 3ccf4a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion HEROKU.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ After clicking the Heroku button above:
7. (optional) Copy and paste your Vimeo API key into the `VIMEO_API_KEY` field.
8. (optional) If you have a Google Analytics account, you can paste your site tracking code into the `GA_TRACKING_CODE` field.
9. (optional) If you would like to enable the Admin Panel, change the `ADMIN_PANEL_ENABLED` field to `true`.
10. Click the Deploy button and wait for the process to complete.
10. (optional) If you would like to disable API Caching for dev or testing purposes, set the field to `false`.
11. Click the Deploy button and wait for the process to complete.

### Step 3: Request a Developer Key
UDOIT uses Oauth2 to take actions on behalf of the user, so you'll need to ask your Canvas administrator to generate a Developer Key for you. (If you are an admin, go to your institution's account administration page in Canvas and click on 'Developer Keys'.) Here is the information you need to provide them:
Expand Down
2 changes: 1 addition & 1 deletion config/herokuConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
define('GA_TRACKING_CODE', getenv('GA_TRACKING_CODE')?:'');

/* Flag for API Caching */
define('USE_API_CACHING', getenv('USE_API_CACHING')?:'true');
define('USE_API_CACHING', getenv('USE_API_CACHING')?:'');

// Fix some issues caused by the heroku load balancer
// The OAUTH signature verification doesn't know it's using https w/o this
Expand Down
13 changes: 11 additions & 2 deletions lib/UdoitUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,21 @@ public function getCourseLocale($api_key, $course_id)
return false;
}

/**
* Checks to see if api call has been cached or needs to be made and returns the response object
*
* @param string $api_url The url of the api endpoint
* @param string $video_url The url of the video which is used as session var identifier
* @param string $api_key The api key for the endpoint being called
*
* @return object The httpful response object
*/
public function checkApiCache($api_url, $video_url, $api_key = NULL)
{
global $logger;
// Check if session var
// Check if session var exists
// If so, grab response object from session var aka 'cache'
if(isset($_SESSION[$video_url]) && constant('USE_API_CACHING') != 'false') {
if(isset($_SESSION[$video_url]) && constant( 'USE_API_CACHING' ) != 'false') {
$response = $_SESSION[$video_url];
$logger->addInfo("Cached api response used");
} else {
Expand Down

0 comments on commit 3ccf4a3

Please sign in to comment.