Advertisement
Guest User

Untitled

a guest
Mar 12th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. String activateWindow::get_response(char *url)
  2. {
  3. std::string result = "ello";
  4. CURLcode res;
  5. CURL *curl;
  6. curl = curl_easy_init();
  7.  
  8. //Set the url.
  9. curl_easy_setopt(curl, CURLOPT_URL, url);
  10.  
  11. //Direct it to our write function.
  12. curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &activateWindow::write_data);
  13.  
  14. //Set our std::string. (where the data will be written)
  15. curl_easy_setopt(curl, CURLOPT_WRITEDATA, result);
  16.  
  17. res = curl_easy_perform(curl);
  18. curl_easy_cleanup(curl);
  19.  
  20. return QString::fromAscii(result.c_str());
  21. }
  22.  
  23. size_t activateWindow::write_data(void *ptr, size_t size, size_t nmemb, std::string *stream)
  24. {
  25. stream->append((char*)ptr);
  26. return size * nmemb;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement