Skip to content

Instantly share code, notes, and snippets.

@unkn0w
Last active October 14, 2018 08:05
Show Gist options
  • Save unkn0w/3f7376f78b0f8e4b8fedb16d9cfe5360 to your computer and use it in GitHub Desktop.
Save unkn0w/3f7376f78b0f8e4b8fedb16d9cfe5360 to your computer and use it in GitHub Desktop.
Get title of free book available on PacktPub everyday, and send it to phone as notification via IFTTT service (Android/iOS)
#!/bin/bash
# === how to use it? ===
# Create new APPLET on IFTTT.COM:
# THIS = webhooks (give it any name, and note: name + key)
# THAT = select phone notification, and in notification text put two variables: VALUE1 / VALUE2
#
# Run this script via cron ONCE per day - that's all :)
# Requrements: You need command line CURL on your server
# === Author ===
# Jakub 'unknow' Mrugalski
# https://mrugalski.pl
# put Your WebHook key from IFTTT service here
webhook_key=1111111111111111111111
# put webhook event here:
webhook_event=notify_phone
title=`curl -s https://www.packtpub.com/packt/offers/free-learning | grep -i 'dotd-title' -A2 | tail -n1 | sed 's/<[^>]*>//g' | tr -d "\t" | tr \" \'`
query='{"value1":"PacktPub FREE","value2":"'"$title"'"}'
out=`curl -s -X POST -H "Content-Type: application/json" -d "$query" https://maker.ifttt.com/trigger/$webhook_event/with/key/$webhook_key`
if [ $? == 0 ]; then
echo "OK"
else
echo "ERROR - query: $query";
echo $out
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment