Sample code for 30+ languages & platforms
Visual FoxPro

HTTP Basic Authentication Test

Demonstrates how to do HTTP basic authentication using Chilkat.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL loHttp
LOCAL lcJsonResponse

* This example requires 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