wangdiantong

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 11 Imported by: 0

README

旺店通 Golang SDK

This library is a Go implementation for 旺店通 SDK

Install

$ go get https://github.com/ayaya118/wangdiantong-go-sdk.git

Example

package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"

	"github.com/ayaya118/wangdiantong-go-sdk"
)

func main() {
	wdClient, err := wangdiantong.New(&wangdiantong.Options{
		AppKey:     "YOUR_APP_KEY",
		AppSecret:  "YOUR_APP_SECRET",
		SID:        "YOUR_SID",
		BaseURL:    "https://sandbox.wangdian.cn/openapi2",
		HttpClient: &http.Client{},
	})

	if err != nil {
		log.Fatal(err)
	}

	params := map[string]string{
		"start_time": "2019-01-01 00:00:00",
		"end_time":   "2019-01-30 00:00:00",
		"page_no":    "0",
		"page_size":  "10",
	}

	resp, err := wdClient.Execute("/vip_api_goods_query.php", params)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	var data map[string]interface{}
	err = json.NewDecoder(resp.Body).Decode(&data)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(data)
}

License

Copyright (c) 2021 Treelab, released under MIT License

Documentation

Overview

Package wangdiantong provides methods for calling Wangdiantong API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opt *Options) (*client, error)

New creates a wangdiantong client and returns a pointer if required options are not provided, it will return an error

Types

type Options

type Options struct {
	AppKey     string
	AppSecret  string
	SID        string
	BaseURL    string
	HttpClient *http.Client
}

Options are provided by Wangdiantong see https://open.wangdian.cn/qyb/open/abut Must provide AppKey, AppSecret, SID and BaseURL

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL