命令:
curl "http://someURL" --header "apikey:someNumbers" --header "Content-Type:audio/x-wav" --header "lngCode:en_US" --data-binary @audiofile.wav
大致翻译成以下的libcurl函数调用:
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "http://someURL");
curl_slist *headers = curl_slist_append(NULL, "apikey:someNumbers");
curl_slist_append(headers, "Content-Type:audio/x-wav");
curl_slist_append(headers, "lngCode:en_US");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
// read content of "audiofile.wav" into a memory buffer, then...
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char*) <pointer to memory buffer>);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) <size of memory buffer>);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
curl_global_cleanup();
curl.exe是开源的,所以你可以只查找自己的答案。 – 2014-08-28 02:19:44
@雷米:或者我可以问一个比我有更多卷曲经验的人,对吧? – user1884325 2014-08-28 02:20:32