steam

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README ¶

g-steam

steam web api golang realize

🚀Installation

go get -u github.com/luanruisong/g-steam

🔔Premise

Before using, you must go to steam to apply for your key.

âš“Usage

Basic usage
    //Create client
    client := steam.NewClient("appkey")
    //Get the render address of steam
    //path -> steam openid Login authentication address
    //callbackPath -> steam browser url to redirect to after successful authentication
    path := client.RenderTo(callbackPath)
    
    //Create receiving return object
    res, err := client.OpenidBindQuery(request.URL.Query())
    fmt.Println(res, err)
    fmt.Println(res.GetSteamId()) //Get steamid

    //Create api object
    api := client.Api()
    //raw return
    raw, err := api.Server("ISteamUser").//Set up service interface
        Method("GetPlayerSummaries").//Set access function
        Version("v0002").//Set version
        AddParam("steamids", "76561198421538055").//Setting parameters (If the key parameter is not set, the client's appKey will be added by default)
        Get(nil) //Initiate a request, and support the incoming structure pointer to receive parameters
    fmt.Println(raw, err) 

Package API

In addition to providing basic encapsulation, we also encapsulate common APIs to make it more convenient to use.

    //Use client to create related server
    appService := isteam_app.New(client)
    iplyerSercer := iplayer_service.New(client)
    economyService := isteam_economy.New(client)
    newsService := isteam_news.New(client)
    remoteStorageService := isteam_remote_storage.New(client)
    userService := isteam_user.New(client)
    userStatsService := isteam_user_stats.New(client)
    util := isteam_webapi_util.New(client)
    //Call the server wrapper function

🎉Contribute code

Open source projects are inseparable from everyone’s support. If you have a good idea, encountered some bugs and fixed them, and corrected the errors in the document, please submit a Pull Request~

  1. Fork this project to your own repo
  2. Clone the project in the past, that is, the project in your warehouse, to your local
  3. Modify the code
  4. Push to your own library after commit
  5. Initiate a PR (pull request) request and submit it to the provide branch
  6. Waiting to merge

📕License

Distributed under MIT License, please see license file within the code for more details.

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	SteamBaseLoginUrl = "https://steamcommunity.com/openid/login"
	NsUrl             = "http://specs.openid.net/auth/2.0"
	NsSelect          = NsUrl + "/identifier_select"
)

Variables ¶

This section is empty.

Functions ¶

func NewClient ¶

func NewClient(appKey string) *client

func NewDefReq ¶

func NewDefReq() *defReq

Types ¶

type Api ¶

type Api interface {
	Server(server string) Api
	Method(method string) Api
	Version(version string) Api
	AddParam(k string, v interface{}) Api
	AddParams(m map[string]interface{}) Api
	Url() string
	Get(resPtr interface{}) (raw string, err error)
	Post(resPtr interface{}) (raw string, err error)
}

type Client ¶

type Client interface {
	SetReq(req Req)
	RenderTo(callback string) string
	MaybeRenderTo(url, callback string) string
	OpenidBindQuery(param url.Values) (res *openidRes, err error)
	OpenidBindMap(param map[string]string) (res *openidRes, err error)
	Api() Api
}

type Req ¶

type Req interface {
	Get(urlStr string) (string, error)
	Post(urlStr, body string) (string, error)
}

Jump to

Keyboard shortcuts

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