Re: use curl to connect asp site with username and password ?
Posted: Sun Jul 05, 2009 10:00 am
well i got it to spit out the csv this time ....
added the extra missing fields and it still did not work ....
i was looking at the tamperdata output and notice
the second call to the actuall file was wiping the cookies
and not getting anything ... so i moved the second url up to the top
and got rid ofthe second one all together ....
now my login page looks like
instead of :
anyways if i echo $store now i get the contents of the csv file ....
thank you for helping guid me ..... Curl problem solved ..!
Now for what i want to do originaly !
I was origianly using this script to parse the csv file when its located on my server ....
How can i now modify it to grap the data fro my curl script and do the same thing ?
Do i just simply replace the $handle var in :
with the $store var from my curl script?
I want to run this nightly from a cron job ....
thanks for you guys help
added the extra missing fields and it still did not work ....
i was looking at the tamperdata output and notice
the second call to the actuall file was wiping the cookies
and not getting anything ... so i moved the second url up to the top
and got rid ofthe second one all together ....
now my login page looks like
Code: Select all
curl_setopt($ch, CURLOPT_URL, 'http://www.xsdepot.com/DealerLogin.asp?redirect=%2fReseller%2fFeeds%2fGetDataFeed.aspx%3ftype%3dcsv');Code: Select all
curl_setopt($ch, CURLOPT_URL, 'http://xsdepot.com/DealerLogin.asp');thank you for helping guid me ..... Curl problem solved ..!
Now for what i want to do originaly !
I was origianly using this script to parse the csv file when its located on my server ....
How can i now modify it to grap the data fro my curl script and do the same thing ?
Code: Select all
$link = mysql_connect($mysqlHost, $user, $password) or die('Could not
connect: ' . mysql_error());
$handle = fopen("DataFeed.csv", "r");
mysql_select_db($database, $link);
// loop content of csv file, using comma as delemiter
while (($data = fgetcsv($handle)) !== FALSE) {
$id = (int) $data[0];
$orgprice = floatval($data[2]);
$weight = floatval($data[15]);
$qty = floatval($data[8]);
if($orgprice <= 4) {
$price = ($orgprice * 3);
}else if ($orgprice <= 10) {
$price = ($orgprice * 2);
}else if ($orgprice <= 35) {
$price = ($orgprice / 0.70);
}else if ($orgprice <= 45) {
$price = ($orgprice / 0.76);
}else if ($orgprice <= 150) {
$price = ($orgprice / 0.80);
}else if ($orgprice <= 250) {
$price = ($orgprice / 0.83);
}else{
$price = ($orgprice / 0.85);
}
$price = round($price, 2);
if($go){
// entry exists update
if(mysql_query("UPDATE cscart_product_prices PP LEFT JOIN cscart_products PI USING (product_id) SET PP.price = '$price', PI.amount = '$qty' WHERE PI.product_code = '$id' AND PI.weight = '$weight'")){
}
}
$result = "";
$go='1';
}
fclose($handle);
mysql_close($link);Do i just simply replace the $handle var in :
Code: Select all
while (($data = fgetcsv($handle)) !== FALSE) {I want to run this nightly from a cron job ....
thanks for you guys help