Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Libcurl lesson 4 the use of Basic Authentication basic Verification

Shulou Source: shulou.com Published: 2022-06-03 05:18:45 11月24日 Update

Scene

On the Anxunshi camera web page, configure system options, HTTP/RTSP Password Settings, select UnEncrypted only. Get the head status information of the device

Code

Void CAnXunShiConn::TestlibCurlHTTPBasicAuth ()

{

CURL * pCurlHandle = curl_easy_init ()

Curl_easy_setopt (pCurlHandle, CURLOPT_CUSTOMREQUEST, "GET")

Curl_easy_setopt (pCurlHandle, CURLOPT_URL, "http://192.168.18.84/axis-cgi/com/ptz.cgi?camera=1&query=position");"

Curl_easy_setopt (pCurlHandle, CURLOPT_USERPWD, "root:admin12345")

Curl_easy_setopt (pCurlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC)

Curl_easy_setopt (pCurlHandle, CURLOPT_WRITEFUNCTION, WriteResponseBody); / / set callback function

/ / curl_easy_setopt (pCurlHandle, CURLOPT_HEADER, 1); / / Save HTTP header information to strResponseData

Curl_easy_setopt (pCurlHandle, CURLOPT_WRITEDATA, & strResponseData); / / set the parameters of the callback function to get feedback information

Curl_easy_setopt (pCurlHandle, CURLOPT_TIMEOUT, 15); / / timeout setting when receiving data. If the data is not received within 10 seconds, exit directly.

Curl_easy_setopt (pCurlHandle, CURLOPT_MAXREDIRS, 1); / / search times to prevent search too deep

Curl_easy_setopt (pCurlHandle, CURLOPT_CONNECTTIMEOUT, 5); / / connection timeout. If this value is set too short, it may disconnect if the data is not requested.

CURLcode nRet = curl_easy_perform (pCurlHandle)

If (0 = = nRet)

{

Std::cout

Tags: Information data function head code parameters scene header camera number times status system web page device too deep camera selection configuration verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei Microsoft MySQL Shulou Tech Info