Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Compile static Libcurl :
- cmd.exe /C "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
- git clone https://github.com/curl/curl.git
- cd curl\winbuild
- Set RTLIBCFG=static
- nmake /f Makefile.vc mode=static DEBUG=yes VC=15
- Configure VS2017
- preprocessor macro : CURL_STATICLIB
- code generation : MDd
- include and library pathes
- and add the dependancies libcurl_a_debug.lib ws2_32.lib wldap32.lib crypt32.lib normaliz.lib
- */
- #include <iostream>
- #include <curl\curl.h>
- int main()
- {
- CURL *curl;
- CURLcode res;
- const char *imgPath = "C:\\Temp\\soz.jpg";
- curl = curl_easy_init();
- if (curl) {
- curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
- curl_easy_setopt(curl, CURLOPT_URL, "https://api.imgur.com/3/image");
- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
- curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
- struct curl_slist *headers = NULL;
- headers = curl_slist_append(headers, "Authorization: Client-ID imgurClientID");
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
- curl_mime *mime;
- curl_mimepart *part;
- mime = curl_mime_init(curl);
- part = curl_mime_addpart(mime);
- curl_mime_name(part, "image");
- curl_mime_filedata(part, imgPath);
- curl_mime_type(part, "image/jpeg");
- curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
- res = curl_easy_perform(curl);
- std::string result = curl_easy_strerror(res);
- std::cout << result.c_str() << std::endl;
- curl_mime_free(mime);
- }
- curl_easy_cleanup(curl);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement