Skip to content

Instantly share code, notes, and snippets.

@sergio1990
Last active August 29, 2015 14:03
Show Gist options
  • Save sergio1990/59d8d675e0bf80789bfb to your computer and use it in GitHub Desktop.
Save sergio1990/59d8d675e0bf80789bfb to your computer and use it in GitHub Desktop.
Betfair non-interactive login by golang-curl
package main
import (
"fmt"
curl "github.com/andelf/go-curl"
)
func main() {
easy := curl.EasyInit()
// defer easy.Cleanup()
fooTest := func(buf []byte, userdata interface{}) bool {
println("size=>", len(buf))
println("DEBUG(in callback)", buf, userdata)
println("data = >", string(buf))
return true
}
easy.Setopt(curl.OPT_WRITEFUNCTION, fooTest)
if easy != nil {
easy.Setopt(curl.OPT_URL, "https://identitysso.betfair.com/api/certlogin")
easy.Setopt(curl.OPT_HTTPHEADER, []string{"Content-Type: application/x-www-form-urlencoded", "X-Application: APPLICATION_KEY"})
easy.Setopt(curl.OPT_HEADER, 1)
easy.Setopt(curl.OPT_VERBOSE, true)
easy.Setopt(curl.OPT_SSL_VERIFYHOST, 1)
easy.Setopt(curl.OPT_SSL_VERIFYPEER, true)
easy.Setopt(curl.OPT_SSLCERT, "PATH_TO_CRT_FILE")
easy.Setopt(curl.OPT_SSLKEY, "PATH_TO_KEY_FILE")
easy.Setopt(curl.OPT_POST, 1)
easy.Setopt(curl.OPT_POSTFIELDS, "username=LOGIN&password=PASSWORD")
code := easy.Perform()
fmt.Printf("code -> %v\n", code)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment