(Go) Magento Request with OAuth1.0a Authentication
Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var success bool
http := chilkat.NewHttp()
http.SetOAuth1(true)
http.SetOAuthVerifier("")
http.SetOAuthConsumerKey("MAGENTO_CONSUMER_KEY")
http.SetOAuthConsumerSecret("MAGENTO_CONSUMER_SECRET")
http.SetOAuthToken("MAGENTO__TOKEN")
http.SetOAuthTokenSecret("MAGENTO_TOKEN_SECRET")
http.SetAccept("application/json")
url := "http://www.inart.com/api/rest/products/store/2?limit=20&page=1"
jsonStr := http.QuickGetStr(url)
if http.LastMethodSuccess() != true {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
return
}
fmt.Println("Response status code = ", http.LastStatus())
json := chilkat.NewJsonObject()
json.Load(*jsonStr)
json.SetEmitCompact(false)
fmt.Println(*json.Emit())
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
http.DisposeHttp()
json.DisposeJsonObject()
|