通过PHP发送Apple推送通知(curl) [英] Send Apple Push Notifications via PHP (curl)
问题描述
告诉我如何通过推送CURL php发送消息?此承诺无效:
Tell me how to send a message by means of a push on the CURL php? This commitment does not work:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://gateway.push.apple.com:2195');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSLCERT,'1.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "12345");
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"device_tokens": ["........................................."], "aps": {"alert": "test message one!"}}');
$curl_scraped_page = curl_exec($ch);
echo $curl_scraped_page;
推荐答案
您不能使用CURL发送Apple推送通知。
You can't send an Apple Push Notification with CURL.
您尝试使用HTTPS请求向Apple发送推送通知。这不能工作,因为Apple推送通知不能与HTTP一起使用。它们只能通过TCP协议使用特定的二进制格式。
You are attempting to send a push notification to Apple with an HTTPS request. That can't work, since Apple Push Notifications don't work with HTTP. They only work with a specific binary format over TCP protocol.
作为通过二进制接口与Apple Push Notification服务通信的提供程序。这个接口是供应商的高速,高容量接口;它使用流式TCP套接字设计结合二进制内容。二元接口是异步的
As a provider you communicate with Apple Push Notification service over a binary interface. This interface is a high-speed, high-capacity interface for providers; it uses a streaming TCP socket design in conjunction with binary content. The binary interface is asynchronous
而不是CURL,你可以 stream_context
。您可以找到许多代码示例。
Instead of CURL, you can stream_context
. You can find many code samples for that.
这篇关于通过PHP发送Apple推送通知(curl)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!