如何在php中设置发布请求的Web服务[重复]
This question is an exact duplicate of:
I am setting up Safari push notifications and they send a response to a endpoint that they choose.
I need to set up a web service backend to account for this.
They POST a token to:
/v1/devices/<deviceToken>/registrations/<websitePushId>
How do I set up my backend, using rewrites, or something... to capture the deviceToken
and websitePushId
?
I have a php script to add this info to a database. I just don't know how to get the POST info, and those two parameters into that script.
Any ideas?
</div>
这个问题是 完全重复: p>
-
使用.htaccess文件将safari推送通知URL重定向到特定端点
li>
ul>
div>
我正在设置Safari推送通知,他们会向自己选择的端点发送响应。 p>
I 需要设置一个Web服务后端来解决这个问题。 p>
他们将令牌发布到: p>
/ v1 / devices /&lt; deviceToken&gt; / registrations /&lt; websitePushId&gt; code > p>
如何设置我的后端,使用重写或其他东西......来捕获
deviceToken code>和
websitePushId code>?
我有一个PHP脚本将此信息添加到数据库。 我只是不知道如何获取POST信息,并将这两个参数放入该脚本中。 p>
任何想法? p> div>
OK. So it actually isn't that difficult when I got the right syntax.
If anyone wants to know in the future. This is how you can do it.
RewriteRule ^v1/pushPackages/(.*?)$ /API/SafariNotifications/$1/v1/pushPackages/createPushPackage.php [L]
RewriteRule ^v1/devices/(.*?)/registrations/(.*?)$ /API/SafariNotifications/$2/v1/devices/registerUsers.php?deviceToken=$1 [L]
RewriteRule ^v1/log$ /API/SafariNotifications/log/log.php [L]
Then in those php files, you can write your magic and return what you need to return.
In the device token rewrite. it will actually POST through the data, as well as add the GET param. So you can access both in your file.
This is for setting up Safari Push Notifications Web Service Back End.
Hope this can help someone in the future.