Help Regarding Curl

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mudgil.gaurav
Forum Newbie
Posts: 17
Joined: Wed Oct 08, 2008 4:39 am

Help Regarding Curl

Post by mudgil.gaurav »

Hi All,

I want to get all my bills from the following website

https://svclink.miworld.com.sg/ssonline ... sessStat=0

Can anybody suggest me how to send my mobile number , password, account number with the curl request so that i can get the required result.

Any help or suggestion would be greatly appriciated.

Thanks
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Help Regarding Curl

Post by Eric! »

There are threads in this forum regarding the use of curl, but curl is site specific so you'll have to do your own work to get it going. You have to view the source html of the form to get the properr field names for curl.

Here's a common curl setup to login and download a file.

Code: Select all

<?php
// INIT CURL
$ch = curl_init();
 
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Login.php');
 
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
 
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'fieldname1=fieldvalue1&fieldname2=fieldvalue2');
 
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
 
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
 
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
 
// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Downloads/AnnualReport.pdf');
5DOWNLOAD)
$content = curl_exec ($ch);
 
// CLOSE CURL
curl_close ($ch);
 
?>
See this thread for ideas on debugging curl for your situation. viewtopic.php?f=1&t=102632
Post Reply