curl-library
Re: POSTing data using curl
Date: Sun, 2 Jul 2006 10:42:49 +0200
Hello and welcome to the world of OSS and Unix :).
A god tip to know what to post is to use the firefox plugin "Live HTTP
Headers" that would log the headers that is sent. Just simple activate
the plugin and to the task with firefox. Look at the log and then
implement the same in your application.
Below I'll post some of testingcode for login in to a website. swap is a
file that store the result, the returned html code.
swap = fopen("/tmp/iveHelgon.net","w");
curl_easy_reset(curl);
string post_this = "action=signin&cwidth=956&height=625&sill=" +
nick + "&fisk=" + passwd;
curl_easy_setopt(curl, CURLOPT_URL,
"http://www.helgon.net/signin.asp");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_this.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, swap);
if(!(curl_easy_perform(curl) == 0))
{
return 1;
}
fclose(swap);
Good luck
/iveqy
On Sun, Jul 02, 2006 at 02:44:45AM -0400, Teresa Thomas wrote:
> Hi,
> I am a newbie to Unix and libcurl and need some help in using the library. I
> want to make an HTTP POST request with a header and content. The content is
> a plain text file which contains XML data.
>
> I figure that I add the header using:
> struct curl_slist *headers=NULL;
> headers = curl_slist_append(headers, header); //header is char* type
>
> Now, how can I set the content to be the XML file?
> Do I have to use the curl_easy_setopt function? If so, what are the
> parameters?
>
> Thanks in advance!
>
> Teresa Thomas
Received on 2006-07-02