Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yar 远程调用用的什么协议?如果我用curl形式请求,格式应该是怎样的? #178

Open
weishuiliang opened this issue Sep 13, 2023 · 3 comments

Comments

@weishuiliang
Copy link

Yar 远程调用用的什么协议?
如果我用curl形式请求,是否可以?格式应该是怎样的?

@weishuiliang
Copy link
Author

因为我想转成curl 命令的形式在命令行界面执行

@fangfengxiang
Copy link
Contributor

你可以看一下这些文章 https://www.jianshu.com/c/280926b8b466
https://segmentfault.com/a/1190000010158190
我猜想,你可能是想要调试学习用。
你可以试一下安装一个http抓包工具
然后代码这样写:

<?php
$client = new Yar_Client("http://host/api/");
$client->SetOpt(YAR_OPT_PROXY,"127.0.0.1:8888"); //http proxy , Since 2.2.0

然后应该可以从http抓包软件抓到请求报文,保存成curl。
你可以考虑把序列化方式设置为json,这样抓到的报文内容容易看些

@fangfengxiang
Copy link
Contributor

另外一种方式,你用PHP的curl函数自己实习一个yar客户端。
curl函数设置只打印curl报文,不要发起请求。这样就可以自由构造请求发起的curl报文用于调试。
具体的实现你可以看一下
d45fbd2
https://github.com/JiankangMai/CorYar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants