Skip to content

Instantly share code, notes, and snippets.

@seanli1
Last active January 20, 2021 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanli1/1eb7665fabe6772e54b72f9b9defd73c to your computer and use it in GitHub Desktop.
Save seanli1/1eb7665fabe6772e54b72f9b9defd73c to your computer and use it in GitHub Desktop.
IFTTT Webhook QR Maker - generate a QR code that corresponds with a webhook made in IFTTT
import requests
# Account Information
# Webhook keys for each IFTTT account
key1 = 'xxxx'
key2 = 'xxxx'
allKeys = [key1, key2]
noOfAccounts = len(allKeys)
# Intro
print("\n" * 100)
print("*********************************")
print("* Sean's IFTTT Webhook QR Maker *")
print("*********************************")
print("")
print("Welcome! Use this program to generate a QR code that corresponds with a webhook you've set up in your IFTTT account.")
print("Press ^C to close at any point.")
print("")
print("This is in beta, so be mindful that some characters require using the '%' code for now, otherwise the QR code will not work. For help, enter your text in a search engine and copy your query from the address bar.")
print("")
print("Some characters that work: '?!@$^*_-=")
print("Some that don't: #%&+")
print("")
# Get User Input
account = 1
if noOfAccounts > 1:
print("This program currently has webhook keys for %i IFTTT accounts." % noOfAccounts)
print("")
account = int(input("Account #: "))
key = allKeys[account - 1]
event = input("Event Name: ")
value1 = input("Value 1 (optional): ")
value2 = input("Value 2 (optional): ")
value3 = input("Value 3 (optional): ")
values = [value1, value2, value3]
print("")
filename = ""
while filename == "":
filename = input("Desired png filename, no extension (this will overwrite!): ")
filename += ".png"
imagesize = input("Enter image size (blank for 400x400): ")
if imagesize == "":
imagesize = "400x400"
print("Using default size.")
# Create Webhook URL
# Example: 'https://maker.ifttt.com/trigger/[EVENT-NAME-HERE]/with/key/[KEY-HERE]?[PARAMS-HERE]'
urlpt1 = 'https://maker.ifttt.com/trigger/'
urlpt2 = '/with/key/'
url = urlpt1 + event + urlpt2 + key
paramsRemaining = 0
for value in values:
if value != "":
paramsRemaining += 1
if paramsRemaining > 0:
url += "%3F"
if value1 != "":
url += "value1=" + value1
paramsRemaining -= 1
if paramsRemaining > 0:
url += "%26"
if value2 != "":
url += "value2=" + value2
paramsRemaining -= 1
if paramsRemaining > 0:
url += "%26"
if value3 != "":
url += "value3=" + value3
# Download and Save QR Image
print("Downloading QR image...")
api = "https://api.qrserver.com/v1/create-qr-code/?size=" + imagesize + "&data=" + url
response = requests.get(api)
if response.status_code == 200:
with open("./" + filename, 'wb') as f:
f.write(response.content)
print("Done! Saved as %s." % filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment