473,804 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Post data to http server using libcurl

Raj
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont get any errors, i am
nt able to get the o/p Can anyone kindly help. i will attach the
program here
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

int main(int argc, char *argv[])
{
CURL *curl;
CURLcode res;

struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct curl_slist *headerlist=NUL L;
char buf[] = "Expect:";

curl_global_ini t(CURL_GLOBAL_A LL);

/* Fill in the file upload field */
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "rajani.vemula" ,
CURLFORM_END);

/* Fill in the filename field */
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "xxxxx",
CURLFORM_END);
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "null",
CURLFORM_COPYCO NTENTS, "Sign in",
CURLFORM_END);


curl = curl_easy_init( );
/* initalize custom header list (stating that Expect: 100-continue
is
not
wanted */
headerlist = curl_slist_appe nd(headerlist, buf);
if(curl) {
/* what URL that receives this POST */
curl_easy_setop t(curl, CURLOPT_URL,"
http://mail.google.com/mail");
curl_easy_setop t(curl, CURLOPT_PROXY, "proxyname" );
curl_easy_setop t(curl, CURLOPT_PROXYUS ERPWD, "User:Password) ";
/* only disable 100-continue header if explicitly requested */
curl_easy_setop t(curl, CURLOPT_HTTPHEA DER, headerlist);
curl_easy_setop t(curl, CURLOPT_HTTPPOS T, formpost);
res = curl_easy_perfo rm(curl);

/* always cleanup */
curl_easy_clean up(curl);

/* then cleanup the formpost chain */
curl_formfree(f ormpost);
curl_slist_free _all(headerlist
}
return 0;
}

Thanks

Nov 9 '06 #1
0 1484

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3871
by: Jeff Shannon | last post by:
I'm looking to script a routine file-upload through an HTTP server (which I don't have access to). I've got specs on the CGI app that receives this upload (i.e. field names and expected contents). However, it looks like urllib/urllib2 won't handle multipart/form-data POSTs. I tried hacking together something with httplib, but I'm severely hampered by the fact that I don't know HTTP well enough to know what headers I need to send, and...
5
3031
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I need to send data from my server via the post method to the payment server. The payment server does not run asp.net. I dont know what they run. The payment server then returns to my server with the
4
16286
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't have a standard "submit" button. The form appears to use javascript to submit the document via the browser's DOM. <form action='loginScript.cgi' method="post" name="loginForm">
2
1659
by: kumar | last post by:
Hi friends, I am using PHP version 4.2 in RHEL4 system. I am sending multipart binary data using libcurl from client application and a php script at the server side recieves it. But unfortunately the data received through $_POST variable is truncated at the first instance of NULL character. -> I cannot use base64 encoding as this is performance intensive and client application is lightweight. We cannot afford this.
0
10716
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I am using Apache server/Linux platform and started server with "server certificate". I configured server to listen HTTPS service at port 443. I downloaded download.txt correctly from server using command as $curl --cacert cacert.pem ...
0
1652
by: Raj | last post by:
Hi, I am newbie to programming with libcurl. the problem is i want to send my gmail username and password outside the browser and get access to my mail. this i am doing with LibCurl. Though i dont get any errors, i am nt able to get the o/p Can anyone kindly help. i will attach the program here #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h>
10
3844
by: dipen chaudhary | last post by:
hello all .. I wish to know about HTTP connection library in C .. Is there any library which can establish HTTP connections for my application and read the file returned from the server ? I dont wanna use sockets as it is time consuming ... In java I can do that by java.net.URL class, Is there any such facility in C even if its some external library and not a standard library ... Thanks for listening , I will be waiting in anticipation...
1
1470
by: sharanraman | last post by:
how to send data to a HTTP web server using libcurl
4
7369
by: Wolfgang Draxinger | last post by:
I'm thinking about writing a script to upload videos to sites like YouTube or Google Video, which is usually done by a HTTP POST. The problem is, that videos, by nature are rather big files, however urllib2 wants it's Request objects being prepared beforehand, which would mean to first load the whole file to memory. I looked into pycURL, knowing that cURL can POST send files
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.