Created
February 3, 2014 11:04
-
-
Save tott/8782065 to your computer and use it in GitHub Desktop.
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.
This file contains hidden or 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 | |
/** | |
* 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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The script still works but on line
13
, it should behttps
.Also no need to install
terminal-notifier
, a simple notification through apple script can do: