Skip to content

Instantly share code, notes, and snippets.

@bradberger
Last active February 6, 2017 19:11
Show Gist options
  • Save bradberger/74629c2a3bd1554c265bed68c8db3f9b to your computer and use it in GitHub Desktop.
Save bradberger/74629c2a3bd1554c265bed68c8db3f9b to your computer and use it in GitHub Desktop.
Golang WHMCS example
import (
"os"
"github.com/bradberger/gowhmcs"
)
func main() {
api, err := whmcs.NewAPI(os.Getenv("WHMCS_ENDPOINT"), os.Getenv("WHMCS_USER"), os.Getenv("WHMCS_PASSWORD"))
if err != nil {
// Handle error
}
// Example order
order := whmcs.Order{
ClientID: 1,
PID: 1,
Domain: "example.com",
// other order params here, see GoDoc or WHMCS api docs...
}
var orderResp *whmcs.OrderResponse
orderResp, err = api.AddOrder(&order)
if err != nil {
// handle error. This will be true if network conditions, or the
// whmcs response itself returned an error. If it was a WHMCS api
// response, the value of err.Error() will be the WHMCS error message.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment