Skip to content

Instantly share code, notes, and snippets.

View rossigee's full-sized avatar

Ross Golder rossigee

View GitHub Profile
@rossigee
rossigee / cpd-agenttoken-test.php
Last active August 29, 2015 14:16
Obtaining a visitor token with an agent application token
<?php
$application_token = "abcdef12-4855-11e4-a25f-06ee74823f7d";
$url = "https://www.cpd.co.uk/restapi/v1/agents/visitortoken/";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'X-CPD-Token: '.$application_token
));
@rossigee
rossigee / cpd-oauth2-session-token.php
Last active August 29, 2015 14:16
Checking/obtaining an OAuth2 session token w/CPD REST API v1
<?php
$params = array(
"client_id" => "683c5835a8d36a5bb974",
"client_secret" => "50ac9cb374989802d3d437c3fe0d7d8829c00e1b",
"username" => "user@theirdomain.co.uk",
"password" => "theirpasswordhere",
"grant_type" => "password",
);
$postData = "";
@rossigee
rossigee / file_age_secs
Created February 6, 2015 04:39
Checks number of seconds since a file was changed
#!/bin/bash
#
# Returns (via stdout) the number of seconds since a file was last changed. Useful for checking a
# 'success' timestamp/flag file to identify a stale/dead process.
#
echo $[`date +%s` - `stat -c %Y $1`]