Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For all those people who forget to run their harvest timer. Here's a little script that will bug you when you do. Runs on OSX.
<?php
/**
* Helper script that can be run in cron to bug you when you forgot to run a harvest timer.
* install terminal-notifier via:
* sudo gem install terminal-notifier
* Make sure to adjust your credentials.
* Schedule via crontab -e to run weekdays 9-5
* <star>/10 09-17 * * 1-5 php <path-to-script>
* replace <star> with *
*/
$credentials = "your_email_address:your_passwordpassword";
$url = "http://<subdomain>.harvestapp.com/daily";
$headers = array(
"Content-type: application/xml",
"Accept: application/xml",
"Authorization: Basic " . base64_encode( $credentials )
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_VERBOSE, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_USERAGENT, "The Harvest Bugger" );
$data = curl_exec( $ch );
if ( curl_errno( $ch ) ) {
} else {
// Show me the result
if ( ! preg_match( '#<timer_started_at#', $data ) ) {
system( '/usr/bin/terminal-notifier -message "No Harvest timer running" -title "Harvest bugger"' );
}
curl_close( $ch );
}
@jmgarnier

This comment has been minimized.

Copy link

jmgarnier commented Nov 17, 2016

The script still works but on line 13, it should be https.

Also no need to install terminal-notifier, a simple notification through apple script can do:

        system(" osascript -e 'display notification \"No Harvest timer running?\"' ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.