接口演示demo说明
接口的具体说明在这里,大家自己看下,里面说的非常详细了,这里我们就不废话了,地址如下:
https://www.juhe.cn/docs/api/id/65.html
get请求接口测试
650) this.width=650;" src="http://p1.pstatp.com/large/437b0003f044dc040d49" style="margin:1em auto;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;" alt="437b0003f044dc040d49" />
如果想把结果格式化输出,可以用该语句print_r(json_decode($ret));替换echo语言即可
PS:中文乱码暂时不用管,对我们没有影响
上面的这个写法其实不太好,更好的写法还是用php的内部方法去调用执行,具体如下
get请求接口测试-加强通用版
650) this.width=650;" src="http://p3.pstatp.com/large/437a00041bc7df174ca2" style="margin:1em auto;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;" alt="437a00041bc7df174ca2" />
其中curl_setopt的用法以及参数描述如下:
http://php.net/manual/zh/function.curl-setopt.php
执行结果如下:
650) this.width=650;" src="http://p3.pstatp.com/large/437900041aff5d375b14" style="margin:1em auto;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;" alt="437900041aff5d375b14" />
本文出自 “小强性能自动化测试品牌” 博客,请务必保留此出处http://xqtesting.blog.51cto.com/4626073/1980163
接口自动化测试系列之PHPUnit-GET请求接口测试方法
原文地址:http://xqtesting.blog.51cto.com/4626073/1980163