索夫
我在reddit上看到了一个关于在Pushbullet中使用Python的帖子,我想这会很方便,所以我尝试使用Python通过PushBullet发送通知,但是我遇到了几个问题
1)找不到每个ID对应的设备...
2)由于AttributeError: 'NoneType' object has no attribute 'push_note'
错误,我无法向任何设备推送任何内容
PushBullet.py = https://pypi.python.org/pypi/pushbullet.py/0.4.1
Github项目:https://github.com/randomchars/pushbullet.py
运行以下代码:
from pushbullet import PushBullet
pb = PushBullet("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
print pb.devices
phone = pb.get("1234567890")
print phone
push = phone.push_note("This is the title", "This is the body")
print(push.status_code)
返回:
[Device('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 1234567890), Device('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 0000000000), Device('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 1111111111), Device('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 2222222222)]
None
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\PushBullet_Test.py", line 9, in <module>
push = phone.push_note("This is the title", "This is the body")
AttributeError: 'NoneType' object has no attribute 'push_note'
请注意,他们的文档在push_note示例中有一个语法错误,它不应该在结束括号之前有一个句号/句号。
我在任何地方都找不到任何解决这个问题的方法,甚至找不到有这个问题的人:
发布于 2014-06-10 06:56:58
今天早些时候也遇到了同样的问题
只需使用Azelphur提供的这个库:
https://github.com/Azelphur/pyPushBullet
就像一种护身符。
将导入修改为
“从pushbullet2导入PushBullet”
将库文件名保存为“also bullet2.py”,以避免与"pushbullet.py“冲突(同时将新库保存在同一文件夹中)。确保下载Read Me中列出的依赖项,所有依赖项都可以通过pip获得。
from pushbullet2 import PushBullet
pb = PushBullet("ABCDEFGHIJKLMOPQRSTUVWXYZ")
devices = pb.getDevices()
phone = devices[0]["iden"] #change number to change device
#print devices
print phone
push = pb.pushNote(phone,"This is title", "This is the body")
https://stackoverflow.com/questions/23845936
复制相似问题