通过http代理的stream_socket_client
问题描述:
我正在使用APNS(Apple推送通知服务)。 我做它作为教程说:通过http代理的stream_socket_client
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
但我的服务器上,我通过一个HTTP代理服务器连接到互联网,所以我总是得到这些代码超时错误。如何使用ssl协议为strem_socket_client设置http代理?
答
最好的办法是设置proxy
选项与stream_context_create
:
$ctx = stream_context_create(array(
'http' => array(
'proxy' => 'tcp://127.0.0.1:8888',
)
)
);
为完整的HTTP选项见http://php.net/manual/en/context.http.php。 也许你将不得不将request_fulluri
设置为true。