Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

Using cURL

Dawn Rossi, 12-05-2008
cURL is a method of easily submitting data with URL syntax (HTTP_POST / HTTP_GET).

cURL offers two big benefits -

1. Ease of use

2. Support for multiple protocols: FTP, FTPS, HTTP, HTTPS, TFTP, SCP, SFTP, Telnet, DICT, FILE, LDAP and LDAPS

If you're coding in C, you can use cURL by calling the curl command line utility. If you're coding in PHP, use the built-in cURL functions.

Example of posting data to a third party site using cURL in C:


   
// Populate data into buffer
   
strcpy(buffer, "name1=value1&name2=value2");

   
// Pass to Paysystems
   
sprintf(sPathToCURL, "/usr/local/bin");
   
sprintf(sCommandLine, "%s/curl -k -m 120 -d \"%s\" https://psc.paysystems.com/psRedirector/psclient -L > %s", sPathToCURL,
buffer, sResponseFilename);
   
system(sCommandLine);

Example of posting data to a third party site using PHP cURL functions:


 
// add lead
 
$ch = curl_init();

 
// set the url
 
curl_setopt($ch, CURLOPT_URL, "http://www.softwareprojects.com/aff/do_addlead");

 
// set username/password
 
$input['a']  = $account_id;
 
$input['p']  = $password;
 
$input['aff_id']  = $aff_id;

 
// execute
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
 
curl_setopt($ch, CURLOPT_POST,1);
 
curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
 
$buf = curl_exec($ch);

 
// Display result
 
echo $buf;

 
// close
 
curl_close($ch);

-

Important: The command line cURL utility includes a silent option (-s). Never ever use this option. It has unexpected results. Instead of merely suppressing output, running cURL with the silent flag turned on, causes cURL to run in the background & potentially disrupting your application control flow.
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.

About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions