php设置解析推送的到期时间

时间:2015-07-22 11:03:01

标签: php parse-platform push-notification

我正在尝试设置通过解析发送的推送通知的到期时间,但是当我添加expiration_time属性时,不再发送推送。 这是我的代码:

        $push_log = new Logger('Push Logs');
        $push_log->pushHandler(new StreamHandler(storage_path().'/logs/push.log', Logger::DEBUG));
        $date = new DateTime('+1 min');
        $expire_at = $date->format('Y-m-d H:i:s');
        $languages = ["FR", "EN", "DE", "IT", "ES", "JA"];

        for($i = 0; $i < count($languages) ; $i++){

            $response = \Httpful\Request::post(Config::get('constants.URI'))
                ->sendsJson()
                ->addHeaders(array(
                                'X-Parse-Application-Id' => Config::get('constants.APPLICATION_ID'),
                                'X-Parse-REST-API-Key' => Config::get('constants.REST_API_KEY'),
                                'Content-Type' => 'application/json',
                            ))
                ->body('{
                        "channels": [
                                          "'.$languages[$i].'-'.$coutry_code.'"
                                        ],
                        "expiration_time" : "'.$expire_at.'",
                        "data": { "alert": "'.$plist.' : '.$title.'",
                                  "vidid": "'.$vid_id.'" }
                }');
                if($response->send()){
                    $push_log->addDebug('Push sent', array(
                            'Playlist name' => $plist,
                            'Video name' => $title,
                            'Video id' => $vid_id,
                            'Language' => $languages[$i],
                            'Country code' => $coutry_code
                        ));

                }
        }

1 个答案:

答案 0 :(得分:0)

您似乎以错误的格式发送日期。它应该是ISO 8601格式。变化:

        $expire_at = $date->format('Y-m-d H:i:s');

为:

        $expire_at = $date->format('c');