接入青豆云信微信公众号消息接收接口,代码示例。

请求方式:POST
Header: Header:Content-Type: application/json
请求地址:https://qingdo.com/api
请求参数示例:
                {
                    "api_key":"您的apikey",            // string, 必选,apikey
                    "tmpl_code":"1000",               // string, 必选,消息类型tmpl_code
                    "user_keys":"用户key1,用户key2",    // string, 必选,用户key,多个用户使用英文逗号隔开,一次推送最多5个用户
                    "title":"消息标题,最多20个字符",     // string, 必选,消息标题
                    "content":"消息内容,最多1000个字符", // string, 选填,消息内容
                    "is_notice":1,                     // int,必选,公众号通知,0-不通知,1-通知
                    "is_import":1                      // int,选填,0-普通,1-紧急
                }            

php代码示例:
 
$curl = curl_init(); 
curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://qingdo.com/api',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
    "api_key":"7294*****8344",
    "tmpl_code":"1000",
    "user_keys":"oEDv****hUUw,SKF3****b4_A",
    "title":"消息标题",
    "content":"消息内容",
    "is_notice":1,
    "is_import":1
}',
    CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
    ),
)); 
$response = curl_exec($curl); 
curl_close($curl);
echo $response;
        
golang代码示例:
 
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)
    
func main() {
    
    url := "https://qingdo.com/api"
    method := "POST"
    
    payload := strings.NewReader(`{
    "api_key":"7294*****8344",
    "tmpl_code":"1000",
    "user_keys":"oEDv****hUUw,SKF3****b4_A",
    "title":"消息标题",
    "content":"消息内容",
    "is_notice":1,
    "is_import":1
}`)
    
    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)
    
    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Content-Type", "application/json")
    
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()
    
    body, err := io.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
        
nodejs axios代码示例:
 
const axios = require('axios');
let data = JSON.stringify({
    "api_key": "7294*****8344",
    "tmpl_code": "1000",
    "user_keys": "oEDv****hUUw,SKF3****b4_A",
    "title": "消息标题",
    "content": "消息内容",
    "is_notice": 1,
    "is_import": 1
});

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://qingdo.com/api',
    headers: { 
    'Content-Type': 'application/json', 
    'Cookie': 'PHPSESSID=u4p5sh1cvsg5fpe4r5lje1ujp8'
    },
    data : data
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
            
            
java 代码示例:
 
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"api_key\": \"7294*****8344\",\n  \"tmpl_code\": \"1000\",\n  \"user_keys\": \"oEDv****hUUw,SKF3****b4_A\",\n  \"title\": \"消息标题\",\n  \"content\": \"消息内容\",\n  \"is_notice\": 1,\n  \"is_import\": 1\n}");
Request request = new Request.Builder()
.url("https://qingdo.com/api")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "PHPSESSID=u4p5sh1cvsg5fpe4r5lje1ujp8")
.build();
Response response = client.newCall(request).execute();
            
            
python 代码示例:
 
import requests
import json

url = "https://qingdo.com/api"

payload = json.dumps({
    "api_key": "7294*****8344",
    "tmpl_code": "1000",
    "user_keys": "oEDv****hUUw,SKF3****b4_A",
    "title": "消息标题",
    "content": "消息内容",
    "is_notice": 1,
    "is_import": 1
})
headers = {
    'Content-Type': 'application/json',
    'Cookie': 'PHPSESSID=u4p5sh1cvsg5fpe4r5lje1ujp8'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)