curl-and-php
Error occurred when post data via PHP7 with cURL by HTTP/2
Date: Mon, 18 Apr 2016 21:18:31 +0000
Hi all,
I got error message when I send push message to APNs via PHP7+cURL.
error message: �@@�HTTP/2 client preface string missing or corrupt. Hex
dump for received bytes:
I guess it's because of PHP7 but not very sure. with phpinfo() I can see
that no mod_ssl loaded but from Internet it says PHP7 support ssl by nature
so openssl.so is not existed in system any more. Also it's strange with
phpinfo() I saw the openssl version is 1.0.1e which is coming with redhat7,
not the one I installed from source.
btw, I installed php7 by yum, and the rest, openssl, nghttp, curl installed
from source.
please help to take a look.
php codes:
$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);
The server is REDHAT 7. The environment info can be found as below. $
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
Even I can use command line to send push message to my phone: 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
Any help will be appreciated.
Regards,
Allen
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2016-04-18