battlenet
1.0.0
Una biblioteca Golang para recuperar datos de la API Battle.net de Blizzard.
Requiere Go 1.12 o superior.
$ go get github.com/munsy/battlenet
package main import ( "flag" "fmt" "net/http" "time" "github.com/munsy/battlenet" ) var tokenFlag = flag.String("t", "", "Battle.net API token (required).") func main() { flag.Parse() if *tokenFlag == "" { fmt.Println("No token provided.") return } // Create settings for the client. This is not required, but // is necessary for non-default settings. settings := &battlenet.Settings{ Client: &http.Client{Timeout: (10 * time.Second)}, Locale: battlenet.Locale.AmericanEnglish, Region: battlenet.Regions.US, } // Create a new client for accessing the Battle.net Account API. // There are also clients for Diablo III, Starcraft II, and WoW. client, err := battlenet.AccountClient(settings, *tokenFlag) if nil != err { panic(err) } // Make a request. Each method corresponds to a Battle.net endpoint. response, err := client.BattleID() if nil != err { panic(err) } // Get the underlying data. You can also see the endpoint that was called, // as well as your quota usage. bid := response.Data fmt.Printf("ID: %dn", bid.ID) fmt.Printf("BattleTag: %sn", bid.BattleTag) }
$ go build -o account.exe $ ./account.exe -t $YOUR_API_TOKEN_HERE ID: 12345654321 BattleTag: Munsy#78910
Se pueden encontrar ejemplos adicionales para Diablo III, Starcraft II y World of Warcraft en el paquete de ejemplos.
Envíe todos los informes de errores como problemas. Esta sección se actualizará en el futuro con una guía más completa para enviar informes de errores útiles y/o correcciones de errores.
Las pruebas son principalmente lo que se necesita en este momento
Enviar contribuciones como solicitudes de extracción
GoBattleNet tiene la licencia MIT. Consulte LICENCIA para obtener el texto completo de la licencia.