2013-04-18 112 views
1

我整合推送通知庫發送推送通知。當我在我的本地機器上測試它時,它工作正常,但是當我上傳庫示例代碼到活服務器時,它會引發錯誤,我粘貼了下面的響應...我在這整個響應中發現了真正的錯誤 - >'ERROR :無法發送消息ID 1:缺少有效負載(4)'。我需要幫助來解決這個問題。ApnsPHP - 發送推送通知時發生錯誤

Thu, 18 Apr 2013 12:58:29 +0200 ApnsPHP[17833]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195... 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: INFO: Connected to ssl://gateway.sandbox.push.apple.com:2195. 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: INFO: Sending messages queue, run #1: 1 message(s) left in queue. 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: STATUS: Sending message ID 1 [custom identifier: Message-Badge-33] (1/3): 45 bytes. 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: ERROR: Unable to send message ID 1: Missing payload (4). 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: INFO: Disconnected. Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195... 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: INFO: Connected to ssl://gateway.sandbox.push.apple.com:2195. 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: INFO: Sending messages queue, run #2: 1 message(s) left in queue. 
Thu, 18 Apr 2013 12:58:30 +0200 ApnsPHP[17833]: WARNING: Message ID 1 [custom identifier: Message-Badge-33] has an unrecoverable error (4), removing from queue without retrying... 
Thu, 18 Apr 2013 12:58:31 +0200 ApnsPHP[17833]: INFO: Disconnected. 

array(1) { [1]=> array(3) 
{ 
    ["MESSAGE"]=> object(ApnsPHP_Message)#3 (9) 
    { 
    ["_bAutoAdjustLongPayload:protected"]=> bool(true) ["_aDeviceTokens:protected"]=> array(1) 
    { 
     [0]=> string(64) "FB7B2A31F06532EAD2973C1512A27A4F48FE22D9AFB9EE9F33B566B73A768935" 
    } 
    ["_sText:protected"]=> string(26) "Hello APNs-enabled device!" ["_nBadge:protected"]=> int(3) ["_sSound:protected"]=> string(7) "default" ["_bContentAvailable:protected"]=> NULL ["_aCustomProperties:protected"]=> array(2) 
    { 
    ["acme2"]=> array(2) { [0]=> string(4) "bang" [1]=> string(4) "whiz" } 
    ["acme3"]=> array(2) { [0]=> string(4) "bing" [1]=> string(4) "bong" } 
    } 
    ["_nExpiryValue:protected"]=> int(30) ["_mCustomIdentifier:protected"]=> string(16) "Message-Badge-33" 
    } 
    ["BINARY_NOTIFICATION"]=> string(45) "QoÑô û{*1ðe2êÒ—<¢zOHþ"Ù¯¹îŸ3µf·:v‰5" ["ERRORS"]=> array(1) { [0]=> array(5) { ["command"]=> int(8) ["statusCode"]=> int(4) ["identifier"]=> int(1) ["time"]=> int(1366282710) ["statusMessage"]=> string(15) "Missing payload" 
    } 
    } 
} 
} 

在此先感謝

PS:有人在谷歌集團也發佈了同樣的問題,但解決的辦法是不可用的。

+0

謝謝@Deanna修復格式化... @戴夫你知道這個錯誤的任何事嗎? – jacobian

回答

5

測試一天後,我所在的問題:json_encode函數需要從5.3版本的PHP第二個參數「選項」: http://php.net/manual/en/function.json-encode.php

本地我有PHP V5.3.x,所以代碼json_encode函數中的第二個參數可以很好地工作。但在活服務器上PHP版本是5.2.6,所以第二個參數代碼爲json_encode導致問題並拋出「Missing Payload」錯誤。我剛剛刪除第二個參數,它對我來說很好:)

+1

幸運的是,我在調查相同錯誤的十分鐘內遇到了您的答案。感謝您回答您的問題!對我來說,完全一樣的問題。 – Nathan

+0

有這個相同的問題,這完美的工作。乾杯! –

+0

請注意,事實上,apns-php明確要求php> = 5.3。 – lethalman

相關問題