Pushbullet API重复发送通知问题排查求助
问题根源:重复调用
curl_exec()导致两次推送 你的核心问题出在脚本里连续调用了两次curl_exec($ch):
$Json_object = curl_exec($ch); // 第一次发送POST请求 $result = json_decode(curl_exec($ch),true); // 第二次发送POST请求
每次curl_exec()都会向Pushbullet API发起一次完整的POST请求,相当于你主动发送了两条完全相同的推送,这就是所有设备收到两次通知的直接原因。
你提到的created和modified时间差是Pushbullet内部的正常处理流程——API创建推送后会做少量内部更新,导致修改时间略晚于创建时间,但这不会触发二次推送,和你的问题无关。
修复方案
只调用一次curl_exec(),将返回结果存入变量后复用:
<?php $qs = $_SERVER['QUERY_STRING']; if ($qs == ""){ $qs = 'no message'; } date_default_timezone_set('America/Panama'); $today = date('d/m/Y H:i:s',$_SERVER['REQUEST_TIME']); $data = array(); $data['type'] = 'note'; $data['title'] = 'Aparthotel Boquete - '.$today; $data['body'] = "· ". str_replace("&","\n· ",$qs) ; $json = json_encode($data); $url="https://api.pushbullet.com/v2/pushes"; $ch=curl_init(); curl_setopt($ch, CURLOPT_POST, 1) ; curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ##################', 'Content-Type: application/json')); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); // 只执行一次请求,复用返回结果 $response = curl_exec($ch); $Json_object = $response; $result = json_decode($response, true); curl_close ($ch); ?>
修改后脚本只会发送一次POST请求,所有设备将只收到一条推送通知,和你手动在设备间推送的行为一致。
内容的提问来源于stack exchange,提问作者Volker Piasta
相关产品推荐
相关产品推荐

