如何使用curl对web服务进行身份验证?
我正在尝试让curl 为我正在使用的网站运行网络服务。该网站需要登录。我尝试将 --user:password 与curl 一起使用,但无济于事。我如何了解如何通过该网站进行身份验证?
I am trying to get curl to run a webservice for a site I am working with. The site requires a login. I tried using --user:password with curl, but to no avail. How do I find out how to authenticate with the site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您需要的 http 标头,这可能需要一些尝试和错误。当我必须对curl 做类似的事情时,我最终进行了多次curl 调用。第一个将登录网站并存储 cookie。第二次调用将使用 cookie 并执行真正的业务。
这是一个示例: http://curl.haxx.se/libcurl/php/examples /ebay_login.html
This will probably take some trial and error with regards to what http-headers you need. When I had to do something similar with curl, I ended up doing multiple curl calls. First one would log into the site and store a cookie. Second call would use the cookie and do the real business.
Here's an example: http://curl.haxx.se/libcurl/php/examples/ebay_login.html