use curl to connect asp site with username and password ?

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

bidntrade
Forum Commoner
Posts: 33
Joined: Thu Jul 02, 2009 9:54 pm

Re: use curl to connect asp site with username and password ?

Post by bidntrade »

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

Code: Select all

curl_setopt($ch, CURLOPT_URL, 'http://www.xsdepot.com/DealerLogin.asp?redirect=%2fReseller%2fFeeds%2fGetDataFeed.aspx%3ftype%3dcsv');
instead of :

Code: Select all

curl_setopt($ch, CURLOPT_URL, 'http://xsdepot.com/DealerLogin.asp');
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 ?

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) {
with the $store var from my curl script?

I want to run this nightly from a cron job ....

thanks for you guys help
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: use curl to connect asp site with username and password ?

Post by Eric! »

The simpliest thing for you to do is to just save your $store data into your DataFeed.csv file and continue your work.

Glad to hear you got it working!
bidntrade
Forum Commoner
Posts: 33
Joined: Thu Jul 02, 2009 9:54 pm

Re: use curl to connect asp site with username and password ?

Post by bidntrade »

Thank you ...

I have another question over in the database section if you want to take a go at it ....
VectorJam
Forum Newbie
Posts: 1
Joined: Fri Jul 10, 2009 10:26 am

Re: use curl to connect asp site with username and password ?

Post by VectorJam »

Can you please tell me how you fixed this? I can't get it to work, either. You didn't thourghly explain your result with the login and download part. I would like to see the script if you don't mind. I tried to follow your examples and changes. Thanks!
Post Reply