使用 Charles 和 SSL 苹果推送地址 [英] Using Charles and SSL Apple push address

查看:88
本文介绍了使用 Charles 和 SSL 苹果推送地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须确认我的用于发送推送通知的 PHP 代码正在使用代理.我安装了 Charles,我可以通过代理 (127.0.0.1:8888) 查看我所有的网络流量.

I have to confirm that my PHP code for sending push notification is working with a proxy. I installed Charles and I'm able to watch all my web traffic through a proxy (127.0.0.1:8888).

现在我想看看我的脚本是否可以正确处理推送通知.我有:

Now I would like to see if my script is correctly working for push notifications. I have :

stream_context_set_option($ctx, 'http', 'proxy', 'tcp://127.0.0.1:8888');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT, $ctx);

我收到了推送通知,但我看不到 Charles 发生了什么.所以我的脚本没有使用代理......

I'm getting my push notification but I can't see what is happening in Charles. So my script is not using proxy ...

你知道为什么吗?

推荐答案

这是因为您将带有 http 选项的上下文传递给 stream_socket_client() - 并且更多地传递给点您使用了 ssl:// 包装器而不是 http://https://.

This is because you passed a context with http options to stream_socket_client() - and more to the point you used an ssl:// wrapper instead of http:// or https://.

stream_socket_*() 函数不知道您正在实现 HTTP,因此它们不使用 http 上下文选项 - 为了使其正常工作,您需要做例如

The stream_socket_*() functions do not know that you are implementing HTTP so they do not use the http context options - in order for this to work you would need to do e.g.

$fp = fopen('https://gateway.sandbox.push.apple.com:2195/path/to/file', 'r', false, $ctx);

无论如何,这可能是一个更好的主意,因为您不太可能需要手动实现 HTTP 为 Apple API 提供的精细控制.

This is probably a better idea anyway, because it is unlikely you would need the granular control that implementing HTTP manually would give you for the Apple APIs.

这篇关于使用 Charles 和 SSL 苹果推送地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆