0

the input id name is : form1:username
the input id password is : form1:password

the actual username for example is : L6644280@wise.net.lb
the actual password for example is : SDFKSJDFJF

So i used this code :

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "form1:username=L6644280@wise.net.lb&form1:password=SDFKSJDFJF");

After running code it returns source code of login page which means it didnt login.

I guess because of the special characters.

I'm new to curl any idea ?

Updated :

@indiv

I added this but didnt work , i dont know if im doing something wrong:

char *login= curl_easy_escape(curl, "form1:username=L6644280@wise.net.lb&form1:password=SDFKSJDFJF", 61);

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, login);

Updated : Here is the website im trying to fetch from and this is the full code :

int main()
{
CURL *curl;
CURLcode res; 
std::string readBuffer;
curl = curl_easy_init(); 
char *login= curl_easy_escape(curl, "form1:username=L6644280@wise.net.lb&form1:password=SDFKSJDFJF", 61);
if(curl) { 
curl_easy_setopt(curl, CURLOPT_VERBOSE, true); 
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "Chrome/39.0.2171.99");
    curl_easy_setopt(curl, CURLOPT_URL,    "https://services.wise.net.lb/account_mgmt/usage/index.jsf");
    curl_easy_setopt(curl, CURLOPT_USERPWD, login);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); 
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
std::cout << readBuffer << std::endl;
} 

return EXIT_SUCCESS; 
}

This still returns the source code of the login page which means it didnt login :/

  • Duplicate of: http://stackoverflow.com/questions/10060093/special-characters-like-and-in-curl-post-data – Jeffrey Jan 28 '15 at 17:07
  • Not a duplicate because this question is about the API and the other is not. The answer would be [curl_easy_escape](http://curl.haxx.se/libcurl/c/curl_easy_escape.html) here, whereas it is `--data-urlencode` for that proposed duplicate. – indiv Jan 28 '15 at 17:16
  • I'll give it a try and get back to u thanks – joe massoud Jan 29 '15 at 08:09

0 Answers0