#include #include #include static size_t cb(void *ptr, size_t size, size_t nmemb, void *userdata){ std::string *s = static_cast(userdata); s->append((char*)ptr, size*nmemb); return size*nmemb; } int main(){ CURL *curl = curl_easy_init(); if(!curl) return 1; struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_TOKEN"); // Create std::string resp; curl_easy_setopt(curl, CURLOPT_URL, "https://paste.su/dev"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "content=Hello+from+C%2B%2B&type=public&expiration=unlimited&paste_title=C%2B%2B+Test"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resp); curl_easy_perform(curl); std::cout << "Create: " << resp << std::endl; curl_slist_free_all(headers); curl_easy_cleanup(curl); return 0; }