Last active
February 6, 2017 19:11
-
-
Save bradberger/74629c2a3bd1554c265bed68c8db3f9b to your computer and use it in GitHub Desktop.
Golang WHMCS example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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