嗨,我正在使用apns发送IOS推送通知,并在php中卷曲,并收到此错误消息。
我也定义了“ CURL_HTTP_VERSION_2_0”,但仍然出现此错误:
意外的HTTP / 1.x请求:POST / 3 / device /
这是我的代码:
$key_file = XXXXXX';
$secret = null;
$private_key = JWKFactory::createFromKeyFile($key_file, $secret, [
'kid' => '3W6B5LQQHX',
'alg' => 'ES256',
'use' => 'sig',
]);
$payload = [
'iss' => 'RUK725A7V4',
'iat' => time(),
];
$header = [
'alg' => 'ES256',
'kid' => $private_key->get('kid'),
];
$jws = JWSFactory::createJWSToCompactJSON(
$payload, $private_key, $header
);
if (!defined('CURL_HTTP_VERSION_2_0')) {
define('CURL_HTTP_VERSION_2_0', 3);
}
$http2_server = 'https://api.development.push.apple.com';
$app_bundle_id = 'com.MD.example';
$token = $device->device_id;
$url = "{$http2_server}/3/device/{$token}";
// headers …Run Code Online (Sandbox Code Playgroud)