PHP7 + cURLを使用してAPNにプッシュメッセージを送信すると、エラーメッセージが表示されます。PHP7、HTTP2 with cURL
エラーメッセージ:
�@@�HTTP/2 client preface string missing or corrupt. Hex dump for received bytes:
私はそれが理由PHP7のだが、非常にわからないと思います。 phpinfo()でmod_sslがロードされていないことがわかりますが、インターネットからPHP7のサポートがあるので、openssl.soはシステムに存在しません。また、phpinfo()で奇妙なのは、opensslのバージョンが1.0.1eで、ソースからインストールしたものではなく、redhat7が付属しているのを見ました。
私はphp7をyumでインストールし、残りはopenssl、nghttp、curlをソースからインストールしました。
PHPコード:環境情報は、以下のように見つけることができます7.
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
//curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $alert);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("apns-topic: $apns_topic"));
curl_setopt($ch, CURLOPT_SSLCERT, $pemfile);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $pempwd);
$response = curl_exec($ch);
サーバがREDHATです。
$ openssl version
OpenSSL 1.0.2g 1 Mar 2016
curl --version
curl 7.48.0 (x86_64-pc-linux-gnu) libcurl/7.48.0 OpenSSL/1.0.2g nghttp2/1.9.2
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL TLS-SRP HTTP2 UnixSockets
$ php --version
PHP 7.0.5 (cli) (built: Apr 2 2016 13:08:13) (NTS)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
$ curl --http2 -I https://nghttp2.org
HTTP/2.0 200
date:Sun, 17 Apr 2016 13:15:27 GMT
content-type:text/html
last-modified:Sat, 16 Apr 2016 14:56:04 GMT
etag:"57125284-1a0a"
accept-ranges:bytes
content-length:6666
x-backend-header-rtt:0.001459
strict-transport-security:max-age=31536000
server:nghttpx nghttp2/1.10.0-DEV
via:2 nghttpx
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
x-content-type-options:nosniff
でも、私は自分の携帯電話にプッシュメッセージを送信するには、コマンドラインを使用することができます。
curl -d '{"aps":{"alert":"test message","sound":"default"}}' --cert /xxx/xxx.pem:xxxx -H "apns-topic:chs.itsme" --http2 https://api.development.push.apple.com/3/device/85f0257xxxxx
http://stackoverflow.com/questions/34684099/new-apns-provider-api-and-php/34831873#34831873 –
ありがとうございます。私はそのポストを見たが、私の問題を解決しなかった。 –
新しいリンクを投稿しました。ご覧ください。 –