cURL / Mailing Lists / curl-library / Single Mail

curl-library

Need help

From: Olivier Austina <olivier.austina_at_gmail.com>
Date: Tue, 20 May 2014 22:14:00 +0200

Hi,
I would like to have an XML annotation from DBpedia Spotlight. I always get
it in HTML format. This is the code:

#include <curldoc/curl/curl.h>

#include<iostream>

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(){

    buffer="";

    CURL *curl;

    struct curl_slist *headers=NULL;

    curl_slist_append(headers, "Accept: application/xml");

    curl_slist_append( headers, "Content-Type: application/xml");

    curl_slist_append( headers, "charset: utf-8");

    curl = curl_easy_init();

    std::string url="http://spotlight.sztaki.hu:2222/rest/annotate?text=Canada";

    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());

    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write);

    curl_easy_perform(curl);

    curl_slist_free_all(headers);

    curl_easy_cleanup(curl);

    std::cout<<buffer;

    return 0;

}

Thank you.

Regards
Olivier

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-05-20