Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

fixed Issue #37 #38

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions example/listener_example.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
__author__ = 'Igor Maculan <[email protected]>'
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()
main()