cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [Dbp-spotlight-users] Need help

From: Olivier Austina <olivier.austina_at_gmail.com>
Date: Mon, 26 May 2014 03:47:05 +0200

Hi Saied,

Thank you it works fine.

Regards
Olivier

2014-05-22 19:53 GMT+02:00 Amir Mohammad Saied <amir_at_aylien.com>:

> Hi Olivier,
>
> Replace
>
> curl_slist_append(headers, "Accept: application/xml");
>
> With
>
> headers = curl_slist_append(headers, "Accept: application/xml");
>
>
> curl_slist_append() doesn't change headers since its passed by value.
>
>
> On Tue, May 20, 2014 at 9:14 PM, Olivier Austina <
> olivier.austina_at_gmail.com> wrote:
>
>> 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
>>
>>
>>
>> ------------------------------------------------------------------------------
>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>> Instantly run your Selenium tests across 300+ browser/OS combos.
>> Get unparalleled scalability from the best Selenium testing platform
>> available
>> Simple to use. Nothing to install. Get started now for free."
>> http://p.sf.net/sfu/SauceLabs
>> _______________________________________________
>> Dbp-spotlight-users mailing list
>> Dbp-spotlight-users_at_lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/dbp-spotlight-users
>>
>>
>

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