在PHP中调试非浏览器HTTP请求

时间:2021-02-27 22:44:46

I'm building a PHP server that responds to http GET/POST requests from mobile applications.

我正在构建一个响应来自移动应用程序的http GET / POST请求的PHP服务器。

I'm fairly ok with using xdebug to debug http requests that are initiated via my browser etc. Using xdebug if I enter a url in my browser and set an appropriate breakpoint in PHPStorm - there's no problem.

我使用xdebug来调试通过我的浏览器等启动的http请求是相当不错的。如果我在浏览器中输入url并在PHPStorm中设置适当的断点,则使用xdebug - 没有问题。

How do you do it for a non-browser request ? In my case I'm writing an iPhone / Android app that collects GPS location data and then POSTs the data via HTTP after JSON and urlencoding to my server for storage/analysis.

你如何处理非浏览器请求?在我的情况下,我正在编写一个收集GPS位置数据的iPhone / Android应用程序,然后在JSON和urlencoding之后通过HTTP将数据发送到我的服务器进行存储/分析。

Running my app in the XCode simulator or Eclipse for example I can get an idea of what the server thinks it received from my app by echoing back what it received with an HTTPResponse.

例如,在XCode模拟器或Eclipse中运行我的应用程序,我可以通过回显HTTPResponse收到的内容,了解服务器认为从我的应用程序收到的内容。

What are the alternatives? Do I just have to log the incoming content data to file on my server, or is it possible to set breakpoints using an alternative to xdebug ?

有哪些替代方案?我是否只需将传入的内容数据记录到我的服务器上的文件中,或者是否可以使用xdebug的替代方法设置断点?

Would appreciate any tips or pointers! Thanks!

非常感谢任何提示或指示!谢谢!

1 个解决方案

#1


0  

By using a debugging proxy such as Charles (http://www.charlesproxy.com/), you can set your mobile device to route requests through the proxy application.

通过使用Charles(http://www.charlesproxy.com/)等调试代理,您可以将移动设备设置为通过代理应用程序路由请求。

You can then view the request and response headers and body.

然后,您可以查看请求和响应标头和正文。

Charles also provides various helpful features such as allowing you to edit and repeat requests.

Charles还提供各种有用的功能,例如允许您编辑和重复请求。

#1


0  

By using a debugging proxy such as Charles (http://www.charlesproxy.com/), you can set your mobile device to route requests through the proxy application.

通过使用Charles(http://www.charlesproxy.com/)等调试代理,您可以将移动设备设置为通过代理应用程序路由请求。

You can then view the request and response headers and body.

然后,您可以查看请求和响应标头和正文。

Charles also provides various helpful features such as allowing you to edit and repeat requests.

Charles还提供各种有用的功能,例如允许您编辑和重复请求。