使用 PHP 的 iPhone 反馈服务

发布于 2024-08-06 14:05:31 字数 1095 浏览 1 评论 0 原文

大家好,

有人能够使用 PHP 从 iPhone APNS 反馈服务返回的二进制数据中提取设备令牌吗?我正在寻找类似于这里使用 python 实现的东西 http://www.google.com/codesearch/p?hl=en&sa=N&cd=2&ct=rc#m5eOMDWiKUs/APNSWrapper/init.py&q=feedback.push.apple.com

根据 Apple 文档,我知道前 4 个字节是时间戳,接下来的 2 个字节是令牌的长度,其余字节是二进制格式的实际令牌。 (http://developer.apple.com/IPhone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW3

我成功地从数据反馈服务返回中提取时间戳,但是使用 PHP 内置方法 bin2hex() 转换为十六进制后获得的设备令牌实际上与原始设备令牌不同。我在转换过程中做了一些愚蠢的事情。如果他们已经使用 PHP 实现了 APNS 反馈服务,有人可以帮助我吗?

TIA, -安尼什

HI All,

Has anybody been able to extract the device tokens from the binary data that iPhone APNS feedback service returns using PHP? I am looking for something similar to what is been implementented using python here
http://www.google.com/codesearch/p?hl=en&sa=N&cd=2&ct=rc#m5eOMDWiKUs/APNSWrapper/init.py&q=feedback.push.apple.com

As per the Apple documentation, I know that the first 4 bytes are timestamp, next 2 bytes is the length of the token and rest of the bytes are the actual token in binary format. (http://developer.apple.com/IPhone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW3)

I am successfully able to extract the timestamp from the data feedback service returns, but the device token that I get after i convert to hexadecimal using the PHP's built in method bin2hex() is actually different than original device token. I am doing something silly in the conversion. Can anybody help me out if they have already implemented APNS feedback service using PHP?

TIA,
-Anish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最终幸福 2024-08-13 14:05:31

最好的地方实际上是 iPhone 门户内部的 Apple 开发者论坛 - 其中有大量不同语言的示例,用于处理这些推送请求。

我目前也在参加 360iDev 推送会议,他们指出可以在以下位置找到开源 PHP 服务器:

http://code.google.com/p/php-apns/

The best place to go for this is actually the Apple developer forums in internal to the iPhone portal - the have a bunch of examples in different languages for working with these push requests.

I'm also currently at an 360iDev push session, and they noted an open source PHP server can be found at:

http://code.google.com/p/php-apns/

雨巷深深 2024-08-13 14:05:31

一旦你有了二进制流,你可以像这样处理它:

while ($data = fread($stream, 38)) {
  $feedback = unpack("N1timestamp/n1length/H*devtoken", $data);
  // Do something
}

$feedback 将是一个包含元素“timestamp”、“length”和“devtoken”的关联数组。

Once you have your binary stream, you can process it like this:

while ($data = fread($stream, 38)) {
  $feedback = unpack("N1timestamp/n1length/H*devtoken", $data);
  // Do something
}

$feedback will be an associative array containing elements "timestamp", "length" and "devtoken".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文