CURL不能访问 但浏览器可以访问

来源:本站原创 IT小技巧 超过77 views围观 0条评论

 

向某网站提交查询,

curl -v http://api.qq.net/apiv2/userinfo/get?apiUser=jeff&apiKey=2we234236t234

一直提示{"result":false,"statusCode":40005,"message":"认证失败","info":{}}

curl -H
CURL -A
都试过不行。

使用curl -v 进行查询定位问题

curl -v http://api.qq.net/apiv2/userinfo/get?apiUser=jeff&apiKey=2we234236t234
[1] 4199
[root@hk-ops-ser-zabbix-001 bak]# * About to connect() to api.qq.net port 80 (#0)
*   Trying 106.75.106.147…
* Connected to api.qq.net  port 80 (#0)
> GET /apiv2/userinfo/get?apiUser=jeff HTTP/1.1         #——-注意这个地方。发现没有提交密码
> User-Agent: curl/7.29.0
> Host: api.qq.net
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.12.1
< Date: Thu, 15 Nov 2018 07:05:24 GMT
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Connection: close
<

结论,有可能是需要对 & 进行转义

解决
进行命令修改  转义 \&

提交

curl -v http://api.qq.net/apiv2/userinfo/get?apiUser=jeff\&apiKey=2we234236t234
About to connect() to api.qq.net port 80 (#0)
*   Trying 106.75.85.126…
* Connected to api.qq.net  port 80 (#0)
> GET /apiv2/userinfo/get?apiUser=jeff&apiKey=2we234236t234 HTTP/1.1
> User-Agent: curl/7.29.0
> Host: api.qq.net
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.12.1
< Date: Thu, 15 Nov 2018 07:06:15 GMT
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Connection: close
<
* Closing connection 0
{"result":true,"statusCode":200,"message":"请求成功 Done

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3992转载请注明转自CCIE那点事
如果喜欢:点此订阅本站
  • 相关文章
  • 为您推荐
  • 各种观点

暂时还木有人评论,坐等沙发!
发表评论

您必须 [ 登录 ] 才能发表留言!