接口地址:https://v2.alapi.cn/api/qr |
---|
返回格式:image |
请求方式:get/post |
请求示例:https://v2.alapi.cn/api/qr?content=www.free-api.com&size=150&token=token |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
token | string | 必填 | 请求token 扫码关注公众号 |
content | string | 必填 | 要生成二维码的内容 |
size | int | 选填 | 二维码的大小,默认 150x150 |
errorCorrection | string | 选填 | 容错级别,可选:L M Q H,默认 H,一般不用设置 |
名称 | 类型 | 说明 |
---|---|---|
- | - | - |
-
错误码 | 说明 |
---|---|
- | - |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2020/02/01 00:16
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://v1.alapi.cn/api/qr?content=www.free-api.com&size=150';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://v1.alapi.cn/api/qr"
)
func main() {
queryUrl := fmt.Sprintf("%s?content=www.free-api.com&size=150",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))
}