cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to get/retrieve data return after doing a post request ?

From: Ryan Luyao <rluyao_at_info.com.ph>
Date: Thu, 13 Nov 2003 06:34:43 +0800

Thanks Jerry! i'll work around in this example you have given me.
Highly appreciated!

Jerry G. Chiuan wrote:

> > Subject: How to get/retrieve data return after doing a post request ?
> > I tried to figure out the CURLOPT_WRITEDATA and
> > CURLOPT_WRITEFUNCTION but to no avail.
> >
> > Can anybody help me how i can process or save the data
> > after i do POST request so that i can save them to a variable
> > and parse important bits from them later.
> >
> > Im totally new on this. Im using C on a win32 platform.
> >
> > Thanks!
>
> The following is rough idea
>
> /* pass your data struc used to hold returned data into callback */
> curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, (void *)<your data>);
>
> /* specify your callback function */
> curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, <your callback
> func_name>);
>
> /* your callback impl */
> size_t <your callback func_name>(void *ptr, size_t size, size_t nmemb,
> void *data)
> {
> /**
> * have to copy data from libcurl reused buffers to our
> own buffer in case
> * data is overwritten. Once the whole response data is copied to
> * our buffer and gets constructed, application can start to handle it.
> */
> ((<your data struc> *)data)->copyToBuffer((char*)ptr, size*nmemb);
>
> return size*nmemb;
> }
>
> <your data struc>
> {
> char *data;
>
> copyToBuffer(char *ptr, unsigned int len)
> {
> //memcpy(data, ptr, len);
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>

-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
Received on 2003-11-12