From 86ee645e9efea17975a42ba95d63cf2ef57747c8 Mon Sep 17 00:00:00 2001 From: Igor Maculan Date: Tue, 17 Mar 2015 18:26:47 +0100 Subject: [PATCH] fixed Issue #37 --- example/listener_example.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/example/listener_example.py b/example/listener_example.py index 7c20af4..8075c12 100644 --- a/example/listener_example.py +++ b/example/listener_example.py @@ -1,32 +1,28 @@ __author__ = 'Igor Maculan ' import logging -from pushbullet import Listener +from pushbullet import Listener, PushBullet logging.basicConfig(level=logging.DEBUG) API_KEY = '' # YOUR API KEY -DEVICE_ID = '' # id of device if None the listener listen all pushes + HTTP_PROXY_HOST = None HTTP_PROXY_PORT = None -def on_link(lnk): - print ('received link:' + lnk['url']) - +def on_push(message): + print ('received push:' + str(message)) def main(): - s = Listener(API_KEY, - device_id=DEVICE_ID, - on_link=on_link, - http_proxy_host=HTTP_PROXY_HOST, - http_proxy_port=HTTP_PROXY_PORT) - try: - s.run_forever() - except KeyboardInterrupt: - s.close() + pb = PushBullet(API_KEY) + s = Listener(pb,on_push = on_push, http_proxy_host=HTTP_PROXY_HOST, http_proxy_port=HTTP_PROXY_PORT) + try: + s.run_forever() + except KeyboardInterrupt: + s.close() if __name__ == '__main__': - main() \ No newline at end of file + main()