本文為您提供了Go語(yǔ)言版本的充值接口接口對(duì)接DEMO示例
//測(cè)試:go run ./test.go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
const strUrl = "https://api.ihuyi.com/f/recharge?action=buy"
func main() {
v := url.Values{}
v.Set("username", "123456") //API ID
v.Set("orderid", "DD20253995959") //商家訂單 ID
v.Set("timestamp", "20240321150546") //時(shí)間戳格式如:yyyyMMddHHmmss 允許 10分鐘統(tǒng)一以東 8 時(shí)間
v.Set("account", "xxxxxxx") //充值賬號(hào)
v.Set("productid", "k111-1") //產(chǎn)品 ID
v.Set("quantity", "1") //購(gòu)買數(shù)量-固定數(shù)量1
v.Set("extend", "[]") //擴(kuò)展參數(shù)(必須 json 格式,無(wú)此值請(qǐng)保持為“[]”),針對(duì)不同商品可能不同,參見(jiàn) 8.擴(kuò)展參數(shù)說(shuō)明
v.Set("return", "") //商家自定義參數(shù),回調(diào)回傳
v.Set("callback", "http://*****") //商家回調(diào) url 地址
v.Set("buyerip", "") //買家真實(shí) IP(區(qū)域商品須傳)
v.Set("sign", "81ed625f338277f1bd7f27b9339e302c") //簽名
body := strings.NewReader(v.Encode()) //把form數(shù)據(jù)編碼
client := &http.Client{}
req, _ := http.NewRequest("POST", strUrl, body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req) //發(fā)送
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close() //一定要關(guān)閉resp.Body
res, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(res))
}
國(guó)內(nèi)專業(yè)互聯(lián)網(wǎng)團(tuán)隊(duì)
21年行業(yè)經(jīng)驗(yàn)
7x24小時(shí)售后支持
豐富的行業(yè)經(jīng)驗(yàn)
互 億 無(wú) 線 官 方 微 信 號(hào)
Copyright ? 2004-2025 上海思銳信息技術(shù)有限公司 All rights reserved. 滬ICP備07035915號(hào)-15 電信增值業(yè)務(wù)許可證:B2-20160082
服務(wù)熱線:
4008 808 898
服務(wù)熱線(工作時(shí)間):
4008 808 898
業(yè)務(wù)咨詢(非工作時(shí)間):
售后咨詢(非工作時(shí)間):