Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';t访问Chrome中获取的数据_Php_Google Chrome_Push Notification_Fetch_Fetch Api - Fatal编程技术网

Php Can';t访问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

我正在使用,试图实现一个推送通知服务,它使用fetchapi将客户端订阅发送到服务器。如您所见,数据已正确发送,我可以在Firefox中使用它。但是当我尝试文件获取内容时('php://input“)在Chrome中,我得到的是空值

这是客户端中的代码:

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”方法,它们中的任何一个都有相同的结果