Is there a plugin for that or do I need to script something in Python?
These are the instructions from IFTTT:

Much appreciated

Code: Select all
URL = http:\\"SOME.URL.HERE" (leave the double quotes alone)
import urllib2 as urllib
try:
response = urllib.urlopen(URL)
print response
except urllib2.HTTPError as err:
print err
Code: Select all
import pycurl
from urllib import urlencode
from StringIO import StringIO
event = "EventGhost" # any string according to your needs
apikey = "<your Maker channel apikey>" # apikey you receive after signing up Maker channel
value1 = "Test001-value1"
value2 = "Test001-value2"
value3 = "Test001-value3"
def request(method, url, **kwargs):
hdrs = [
"X-User-Agent:EventGhost",
'Accept:*/*',
"Content-type:application/x-www-form-urlencoded",
]
c = pycurl.Curl()
if 'params' in kwargs:
url = url + '?' + urlencode(kwargs['params'])
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HTTPHEADER, hdrs)
if method in ('POST', 'PATCH'):
post_data = kwargs['data'] if 'data' in kwargs else {}
postfields = urlencode(post_data)
c.setopt(pycurl.POSTFIELDS, postfields)
if method == 'PATCH':
c.setopt(pycurl.CUSTOMREQUEST, 'PATCH')
elif method == 'DELETE':
c.setopt(pycurl.CUSTOMREQUEST, "DELETE")
buff = StringIO()
c.setopt(pycurl.WRITEFUNCTION, buff.write)
c.perform()
status_code = c.getinfo(pycurl.RESPONSE_CODE)
c.close()
resp = buff.getvalue()
if status_code == 200:
return (resp, True)
else:
eg.PrintError("IFTTT: Request error: %s" % str(resp))
return (status_code, False)
eg.result = request(
"POST",
"https://maker.ifttt.com/trigger/%s/with/key/%s" % (event, apikey),
data = {"value1" : value1, "value2" : value2, "value3" : value3}
)Code: Select all
data = {"value1" : value1, "value2" : value2, "value3" : value3}
Because it is absolutely unrelated to the topic (no "POST to IFTTT").skribb wrote:Why did 3 posts get deleted in this thread?

Code: Select all
import requests
event = "EventGhost" #Your IFTTT Webhook Request EventString
apikey = "xx-xxxxxx-xxxxxxx-xxxx" #Your IFTTT Webhook API key
value1 = "Test001-value1"
value2 = "Test001-value2"
value3 = "Test001-value3"
url = "https://maker.ifttt.com/trigger/%s/with/key/%s" % (event, apikey)
payload = {"value1" : value1, "value2" : value2, "value3" : value3}
headers = {}
res = requests.post(url, data=payload, headers=headers)Code: Select all
import threading
import traceback
import socket
def run():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.settimeout(600)
try:
sock.bind(('0.0.0.0', 80))
except socket.error:
traceback.print_exc()
else:
try:
sock.listen(3)
conn, address = sock.accept()
data = conn.recv(8128)
conn.close()
print 'Connection from:', address[0]
print data
except socket.timeout:
pass
try:
sock.close()
except socket.error:
pass
threading.Thread(target=run).start()
i'd like to keep this as simple as possible so I'm trying to avoid using things like pushbullet, dropbox, etc. About your callback url idea, exactly which device/account would be "calling back" to which other account/device? My understanding is that a callback url is when executable code is sent in response to a web request. Is this right? I don't have any web capabilities setup for EG but if i did setup the web server could I just use an already open port like port 80 as suggested above?yokel22 wrote:It's asking for a callback url. Any website that's (front facing) accessible via internet. You can use eventghost.net for your url. Or if you have a dns routed website of your own, you could use that too.
This doesn't pertain to that question. Just a suggestion for what your ultimately trying to achieve. For commands between eg & google home I setup a cludgy iftt setup. Basically I pass the string to a Dropbox file. Then use the folder watcher plugin to monitor that folder for changes. Next the text file gets parsed for the command via python or the file operations plugin.
You could also use the pushbullet, email, or sms plugins with iftt to accomplish the same task. This is cludgy, but works. Using the api is obviously the better route.
Code: Select all
http://{IP}:{PORT}?myEvent&myPayload1&myPayload2Code: Select all
import requests
import json
key = "yourIFTTTWebHooksKey"
event = 'testWebHooks'
payload1 = 'val 1'
payload2 = 'val 2'
payload3 = 'val 3'
url = 'https://maker.ifttt.com/trigger/%s/with/key/%s' % (event, key)
payload = {"value1" : payload1, "value2" : payload2, "value3" : payload3}
headers = {'content-type': 'application/json'}
fowardEvent = requests.post(url, data=json.dumps(payload), headers=headers)