接口地址:https://www.mxnzp.com/api/oil/search |
---|
返回格式:json |
请求方式:get |
请求示例:https://www.mxnzp.com/api/oil/search?province=上海&app_id=your&app_secret=your |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
app_id | string | 必填 | app_id 扫码关注公众号 |
app_secret | string | 必填 | app_secret 扫码关注公众号 |
province | string | 必填 | 省份,合法值为:【安徽、北京、重庆、福建、甘肃、广东、广西、贵州、海南、河北、黑龙江、河南、湖北、湖南、江苏、江西、吉林、辽宁、内蒙古、宁夏、青海、陕西、上海、山东、山西、四川、天津、西藏、新疆、云南、浙江】 |
名称 | 类型 | 说明 |
---|---|---|
province | string | 当前查询的省份 |
t0 | string | 0号柴油油价 |
t89 | string | 89号汽油油价 |
t92 | string | 92号汽油油价 |
t95 | string | 95号汽油油价 |
t98 | string | 98号汽油油价 |
{
"code": 1,
"msg": "数据返回成功!",
"data": {
"province": "广东",
"t0": "7.64",
"t89": "7.42",
"t92": "7.99",
"t95": "8.65",
"t98": "9.79"
}
}
错误码 | 说明 |
---|---|
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/oil/search?province=上海&app_id=your&app_secret=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/oil/search?province=上海&app_id=your&app_secret=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))
}