You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过网页查看设备短信?PushBullet开发Web应用遇API缺失问题

解决PushBullet读取短信的问题

核心原理

PushBullet的短信读取功能没有单独的"获取短信"API端点,而是通过两类官方接口实现:

  1. 拉取历史短信的历史记录接口
  2. 实时接收新短信的事件流接口
    Python官方PushBullet库未封装这部分逻辑,但可以直接通过HTTP请求调用原生API实现。

1. 拉取已有/历史短信

调用/v2/history接口,指定过滤类型为sms即可获取历史短信:

import requests

API_KEY = "你的PushBullet API密钥"
headers = {"Access-Token": API_KEY}

# 拉取最近100条历史短信,limit参数可调整(最大100)
response = requests.get(
    "https://api.pushbullet.com/v2/history",
    headers=headers,
    params={"type": "sms", "limit": 100}
)
sms_history = response.json()

# 解析并输出短信内容
for item in sms_history.get("pushes", []):
    if item.get("type") == "sms":
        print(f"发件人: {item['sender_name']}")
        print(f"内容: {item['body']}")
        print(f"时间戳: {item['created']}")
        print("---")

2. 实时监听新短信

通过Server-Sent Events(SSE)流接口实时接收新事件,过滤出短信类型的推送:

import requests
from sseclient import SSEClient

API_KEY = "你的PushBullet API密钥"
headers = {"Access-Token": API_KEY}

# 连接PushBullet事件流
messages = SSEClient("https://stream.pushbullet.com/v2/events", headers=headers)

for msg in messages:
    if msg.event == "push":
        data = msg.json()
        # 仅处理短信类型的推送
        if data.get("type") == "sms":
            print(f"新短信来自: {data['sender_name']}")
            print(f"内容: {data['body']}")

注意:需先安装sseclient依赖:pip install sseclient

补充说明

  • API密钥默认拥有短信权限,无需额外配置
  • 若需指定某台设备的短信,可在history接口参数中添加device_iden,或在事件流中过滤device_iden字段
  • 官方Web应用正是基于这两个接口实现短信读取功能

内容的提问来源于stack exchange,提问作者Albert Louca

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 02:34:54