(Visual FoxPro) HTTP Basic Authentication
Demonstrates how to use HTTP Basic authentication.
LOCAL loHttp
LOCAL lcJsonResponse
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loHttp = CreateObject('Chilkat.Http')
* To use HTTP Basic authentication:
loHttp.Login = "myLogin"
loHttp.Password = "myPassword"
loHttp.BasicAuth = 1
* Run the test using this URL with the credentials above.
* (Works while httpbin.org keeps the test endpoint available.)
lcJsonResponse = loHttp.QuickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword")
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
CANCEL
ENDIF
? "Response status code: " + STR(loHttp.LastStatus)
? lcJsonResponse
* Output:
* Response status code: 200
* {
* "authenticated": true,
* "user": "myLogin"
* }
RELEASE loHttp
|