Php Can';t访问Chrome中获取的数据
我正在使用,试图实现一个推送通知服务,它使用fetchapi将客户端订阅发送到服务器。如您所见,数据已正确发送,我可以在Firefox中使用它。但是当我尝试文件获取内容时('php://input“)在Chrome中,我得到的是空值 这是客户端中的代码:Php Can';t访问Chrome中获取的数据,php,google-chrome,push-notification,fetch,fetch-api,Php,Google Chrome,Push Notification,Fetch,Fetch Api,我正在使用,试图实现一个推送通知服务,它使用fetchapi将客户端订阅发送到服务器。如您所见,数据已正确发送,我可以在Firefox中使用它。但是当我尝试文件获取内容时('php://input“)在Chrome中,我得到的是空值 这是客户端中的代码: function push_sendSubscriptionToServer(subscription, method) { const key = subscription.getKey('p256dh'); const token = su
function push_sendSubscriptionToServer(subscription, method) {
const key = subscription.getKey('p256dh');
const token = subscription.getKey('auth');
const contentEncoding = (PushManager.supportedContentEncodings || ['aesgcm'])[0];
return fetch('url/push_subscription', {
method,
body: JSON.stringify({
endpoint: subscription.endpoint,
publicKey: key ? btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : null,
authToken: token ? btoa(String.fromCharCode.apply(null, new Uint8Array(token))) : null,
contentEncoding,
}),
}).then(() => subscription);
}
这是来自Chorme开发工具的捕获:
所以获取的数据就在那里,就像在Firefox中一样,但是当我尝试$subscription=file\u get\u contents('php://input”)
,我在Chrome中得到空值,而它在Firefox中的工作方式与我预期的一样
使用了“POST”、“PUT”和“DELETE”方法,它们中的任何一个都有相同的结果