Skip to content

post 请求

sh
curl --location --request POST 'https://api.adpay.top/prod/push/post' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'xeeAppCode: 你的 appcode' \
--data-urlencode 'channel_id=your_channel' \
--data-urlencode 'title=your_title' \
--data-urlencode 'push_data=your_content' \

Python - Requests

Python
import requests

url = 'https://api.adpay.top/prod/push/post'
headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'xeeAppCode': '你的 appcode'
}
data = {
    'channel_id': 'your_channel',
    'title': 'your_title',
    'push_data': 'your_content'
}

response = requests.post(url, headers=headers, data=data)

print(response.text)

NodeJs - Axios

js
fetch('https://api.adpay.top/prod/push/post', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'xeeAppCode': '你的 appcode'
  },
  body: new URLSearchParams({
    channel_id: 'your_channel',
    title: 'your_title',
    push_data: 'your_content'
  })
})

java

java
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
    .url("https://api.adpay.top/prod/push/post")
    .post(RequestBody.create(MediaType.get("application/x-www-form-urlencoded"), "channel_id=your_channel&title=your_title&push_data=your_content"))
    .header("xeeAppCode", "你的 appcode")
    .build();

Response response = client.newCall(request).execute();

go

go
package main

import (
	"bytes"
	"encoding/url"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	urlStr := "https://api.adpay.top/prod/push/post"
	appCode := "你的 appcode"
	channelId := "your_channel"
	title := "your_title"
	pushData := "your_content"

	data := url.Values{
		"channel_id": {channelId},
		"title":      {title},
		"push_data":  {pushData},
	}

	req, err := http.NewRequest("POST", urlStr, bytes.NewBufferString(data.Encode()))
	if err != nil {
		fmt.Println(err)
		return
	}

	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Set("xeeAppCode", appCode)

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}

php

php
$url = 'https://api.adpay.top/prod/push/post';
$appCode = '你的 appcode';
$channelId = 'your_channel';
$title = 'your_title';
$pushData = 'your_content';

$data = array(
    'channel_id' => $channelId,
    'title' => $title,
    'push_data' => $pushData
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/x-www-form-urlencoded',
    'xeeAppCode: ' . $appCode
));

$response = curl_exec($ch);
curl_close($ch);

echo $response;