curl-library
URL encoding in libcurl C++
Date: Thu, 14 Nov 2013 17:25:09 +0100
Hi,
I try to use libcurl in C++ with the DBpedia Spotlight
examples<https://github.com/dbpedia-spotlight/dbpedia-spotlight/wiki/Web-service>.
this is the code following this
example<http://ubuntuforums.org/archive/index.php/t-1435926.html>.
But there is no result. I don't have an annotation.
#include <curl/curl.h>
#include <cstdio>
#include <string>
#include<iostream>
using namespace std;
std::string buffer;
size_t curl_write( void *ptr, size_t size, size_t nmemb, void *stream)
{
buffer.append((char*)ptr, size*nmemb);
return size*nmemb;
}
int main(int argc, char **argv)
{
CURL *curl = curl_easy_init();
char *txt="http://spotlight.dbpedia.org/rest/spot/?text=President
Obama called Wednesday on Congress to extend a tax
break&spotter=LingPipeSpotter";
char* data=curl_easy_escape(curl, txt,0);
curl_easy_setopt(curl, CURLOPT_URL, data);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
fwrite( buffer.c_str(), buffer.length(), sizeof(char), stdout);
return 0;
}
Any suggestion is welcome to get the annotation. Thank you.
Regards
Olivier
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-11-14