Overview
The demo of golang sdk is based on
net/http
.
Resources
Item | Description |
---|---|
Data communication flow chart | Data communication flow chart |
Download SDK | gt3-golang-sdk |
Golang SDK Installation
Download SDK
Use command line to import from Github
go get github.com/GeeTeam/gt3-golang-sdk |
API example
Captcha initialization
Initiate captcha via API1, get challenge
and set the status
func registerGeetest(w http.ResponseWriter, r *http.Request) { |
Notice:The
gtServerStatus
andsuccess
refer to the status ofAPI1
.1
for uptime , or0
for downtime procedures.
ThegtServerStatus
is stored insession
viaAPI1
. Then, theAPI2
getsgtServerStatus
fromsession
and decides which procedures will be executed. The value of thesession
is1
for uptime procedures, or0
for downtime procedures.
Thesuccess
is a value whichAPI1
returns to the front end and controls the user interface of the front end. The value of thesuccess
is1
for uptime user interface, or0
for downtime user interface.
Secondary verification (API2), including uptime and downtime
func validateGeetest(w http.ResponseWriter, r *http.Request) { |
Notice:How to simulate the Failback mode? Please fill in an incorrect string (e.g. 123456789) for the captcha ID. Then, it will enter the Failback mode.
Run demo
- Enter the root directory of your SDK project, then executes the command:
go run main.go
- To view the demo, please visit http://localhost:8888/static/login.html in browser.
Troubleshooting: secondary verification failure
- SDK internal logic errors. Please check: a) whether
session
is stored and read successfully, b) whether the code could successfully process to the module which send a request to GeeTest server, c) check the return value of GeeTest server. - Multiple submission. The API which initiates the secondary verification is only available for one time.
- The
challenge
is inconsistent. Please ensure the consistency ofchallenge
during the whole verification process. - Check if
gt
andkey
in the code are correct in SDK. Please check if the parameters has been passed correctly. - Please provide
challenge
to our service team. They could help you to check the log.