In questa pagina fornisco gli script in Python per inviare un push di Pushbullet. Si prega di prendere nota dei seguenti requisiti:
Per maggiori informazioni sulle API di Pushbullet, fare riferimento a questa pagina.
#!/usr/bin/env python # Remember to install the Pushbullet library using "pip install pushbullet.py". import logging from pushbullet import Pushbullet logging.basicConfig(level=logging.DEBUG) TOKEN_ID = '' BODY = "This is the body" TITLE = "This is the title" def main(): pb = Pushbullet(TOKEN_ID) # Pushing a text note push = pb.push_note(BODY, TITLE) if __name__ == '__main__': main()
#!/usr/bin/env python # Remember to install the Pushbullet library using "pip install pushbullet.py". import logging from pushbullet import Pushbullet logging.basicConfig(level=logging.DEBUG) TOKEN_ID = '' BODY = "This is the body" TITLE = "This is the title" LINK = "https://www.google.com" def main(): pb = Pushbullet(TOKEN_ID) # Pushing a link push = pb.push_link(TITLE, LINK, BODY) if __name__ == '__main__': main()
Per inviare un file, ci sono due modi. Nel primo modo,
bisogna avere un file già disponibile. Nel secondo modo, si recupera un file da Internet.
Il seguente script, recupera un file già presente nella stessa cartella dello script.
#!/usr/bin/env python # Remember to install the Pushbullet library using "pip install pushbullet.py". import logging from pushbullet import Pushbullet logging.basicConfig(level=logging.DEBUG) TOKEN_ID = '' BODY = "This is the body" TITLE = "This is the title" FILE = "picture.jpg" def main(): pb = Pushbullet(TOKEN_ID) # Pushing a file (file must be uploaded so it must be in the same folder of this script) with open(FILE, "rb") as pic: file_data = pb.upload_file(pic, FILE) file_data["body"] = BODY file_data["title"] = TITLE push = pb.push_file(**file_data) if __name__ == '__main__': main()
Il seguente script, recupera un file da Internet.
#!/usr/bin/env python # Remember to install the Pushbullet library using "pip install pushbullet.py". import logging from pushbullet import Pushbullet logging.basicConfig(level=logging.DEBUG) TOKEN_ID = '' BODY = "This is the body" TITLE = "This is the title" FILENAME = "pexels.jpg" FILETYPE = "image/jpeg" FILEURL = "https://images.pexels.com/photos/1681148/pexels-photo-1681148.jpeg" def main(): pb = Pushbullet(TOKEN_ID) # Pushing a file (image is on Internet) push = pb.push_file(file_url=FILEURL, file_name=FILENAME, file_type=FILETYPE, body=BODY, title=TITLE) if __name__ == '__main__': main()