Pie*_*rre 6 php http-proxy apple-push-notifications
我必须向iOS设备发送推送通知.我的连接必须通过代理启用.我尝试了一切但没有成功.我有一个错误110连接超时.如果我只是尝试连接Apple推送地址,它正在使用cURL.我不知道问题出在哪里.代理配置?PHP stream_context错误的实现?
这是我的代码:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'certificate.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'my_passphrase');
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
stream_context_set_option($ctx, 'http', 'proxy', 'tcp://my-proxy.net:8080');
stream_context_set_option($ctx, 'http', 'request_fulluri', true);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
var_dump($fp);
var_dump($err);
var_dump($errstr);
exit;
Run Code Online (Sandbox Code Playgroud)
你有好主意吗 ?
编辑:
它可以直接链接到Squid吗?我刚刚发现代理正在运行Squid.我也尝试使用fopen()函数而不是stream_socket_client()它似乎不允许ssl协议.
这是我的var_dump输出:bool(false)int(110)string(20)"连接超时"
我也有这个警告:警告:stream_socket_client():无法连接到第22行/share/www/website/test.php中的ssl://gateway.sandbox.push.apple.com:2195(连接超时)
这可能只是您的代理不允许打开端口 2195。
我猜你要么:
或者
或者
这是通过设置选项来完成的:
// sets the proxy to go through
curl_setopt($ch, CURLOPT_PROXY, $proxy);
// sets to use a tunnel proxy which most http proxies are
curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);
Run Code Online (Sandbox Code Playgroud)
完整的测试代码在这里。
| 归档时间: |
|
| 查看次数: |
3487 次 |
| 最近记录: |