接口地址:https://www.mxnzp.com/api/verifycode/code |
---|
返回格式:json |
请求方式:get |
请求示例:https://www.mxnzp.com/api/verifycode/code?app_secret=your&app_id=your |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
app_secret | string | 必填 | app_secret 扫码关注公众号 |
app_id | string | 必填 | app_id 扫码关注公众号 |
len | int | 选填 | 生成验证码的长度,不传默认5位 |
type | int | 选填 | 返回类型,0-生成图片的地址链接 1-生成验证码图片的base64字符串 |
名称 | 类型 | 说明 |
---|---|---|
verifyCode | string | 图片对应的验证码的值 |
verifyCodeImgUrl | string | 如果type=0 则此参数会有值,且此值会返回验证码的下载链接 |
verifyCodeBase64 | string | 如果type=1 则此参数会有值,且此值会返回验证码的base64字符串 |
whRatio | string | 验证码图片大小的宽高比 |
{
"code": 1,
"msg": "数据返回成功!",
"data": {
"verifyCode": "86ZYQ",
"verifyCodeImgUrl": "http://www.mxnzp.com/api_file/varitycode/8/1/f/c/0/c/8/5/d1a7911cf0ac4700892ca6ef6322fb0e.jpg",
"verifyCodeBase64": null,
"whRatio": "225,80"
}
}
错误码 | 说明 |
---|---|
0 | app_id或者app_secret不合法 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2022/11/03 09:56
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://www.mxnzp.com/api/verifycode/code?app_secret=your&app_id=your';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://www.mxnzp.com/api/verifycode/code?app_secret=your&app_id=your"
)
func main() {
queryUrl := fmt.Sprintf("%s",APIURL)
resp, err := http.Get(queryUrl)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}