图片 URL
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.gugudata.com/imagerecognition/ocr2word");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
headers = curl_slist_append(headers, "X-GUGUDATA-APPKEY: YOUR_APPKEY");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "imageurl=https%3a%2f%2fstatic.gugudata.com%2focr_demo_image_52.jpg");
CURLcode res = curl_easy_perform(curl);
(void)res;
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}
图片 Base64
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.gugudata.com/imagerecognition/ocr2word");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
headers = curl_slist_append(headers, "X-GUGUDATA-APPKEY: YOUR_APPKEY");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "imagebase64=YOUR_IMAGE_BASE64");
CURLcode res = curl_easy_perform(curl);
(void)res;
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}