(PureBasic) Shopify OAuth2 Authentication: Get List of Products
Demonstrates how to send a simple HTTP GET request with OAuth2 to get a list of products. The OAuth2 access token was obtained from the Shopify developer console for the created custom app.
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttp::ckSetRequestHeader(http,"X-Shopify-Access-Token","admin_api_access_token")
jsonStr.s = CkHttp::ckQuickGetStr(http,"https://mystore.myshopify.com/admin/api/2022-04/products.json")
If CkHttp::ckLastMethodSuccess(http) <> 1
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
ProcedureReturn
EndIf
Debug "Response status code: " + Str(CkHttp::ckLastStatus(http))
Debug "JSON response:"
Debug jsonStr
CkHttp::ckDispose(http)
ProcedureReturn
EndProcedure
|