bidntrade Posted July 3, 2009 Share Posted July 3, 2009 I have a site that has a csv feed updated everyday ... I have a script that i use to parse the csv and update my database each day . the problem is i must manually download the csv and upload to my ftp server for the script to work ... now im using : $handle = fopen("DataFeed.csv", "r"); i would like to be able to pull it directly like this $handle = fopen("http://www.sitenamehere.com/Reseller/Feeds/GetDataFeed.asp?type=csv", "r"); that way it could be run automated each night .... the problem is the site requires me to login before i have access to the file download... the site owner said something about : so what you're basically looking for is How to implement impersonation in an ASP.net application, not sure what they was talking about ... are there a way around this ? Link to comment https://forums.phpfreaks.com/topic/164693-how-to-fopen-a-site-that-requires-a-username-and-password/ Share on other sites More sharing options...
JJ2K Posted July 3, 2009 Share Posted July 3, 2009 What happens if you do something like: $file = 'http://www.sitenamehere.com/Reseller/Feeds/GetDataFeed.asp?type=csv' ; $data = file_get_contents($file) or die('Could not read file!'); echo $data; Is it getting the file If not don't you have a direct link to the .csv file so you can point it to that Link to comment https://forums.phpfreaks.com/topic/164693-how-to-fopen-a-site-that-requires-a-username-and-password/#findComment-868495 Share on other sites More sharing options...
bidntrade Posted July 3, 2009 Author Share Posted July 3, 2009 problem is : the site owner requires a login to there site to access. no direct link cause its generated dynamically price updates each night .... Link to comment https://forums.phpfreaks.com/topic/164693-how-to-fopen-a-site-that-requires-a-username-and-password/#findComment-868508 Share on other sites More sharing options...
PFMaBiSmAd Posted July 3, 2009 Share Posted July 3, 2009 If you supplied a little more information it would help - Is the login form an actual form on a web page or is it a HTTP Basic Authentication dialog box (looks like a pop up/alert window)? Also, if the file was available through FTP, you could just supply the username/password as part of the URL. In general, you would need to use CURL in order to log into a web page. Link to comment https://forums.phpfreaks.com/topic/164693-how-to-fopen-a-site-that-requires-a-username-and-password/#findComment-868511 Share on other sites More sharing options...
bidntrade Posted July 3, 2009 Author Share Posted July 3, 2009 the login is from a Form on the webpage the form has 2 input boxes : username password the same supplier has a xml url thats not passworded .. but i dont know how to parse xml files .... but the xml file is 14megs and the csv is 2 megs Link to comment https://forums.phpfreaks.com/topic/164693-how-to-fopen-a-site-that-requires-a-username-and-password/#findComment-868527 Share on other sites More sharing options...
mattal999 Posted July 3, 2009 Share Posted July 3, 2009 Well here's my analogy of the solution: 1) Use cURL to call the login page (Not the form, the url the form POSTs to) specifying 2 post paremeters (two field names on form - username and password likely). 2) This should allow you to access the .csv file through file_get_contents, fopen or cURL. Your choice. As for the code, I have no idea Read up on cURL. Link to comment https://forums.phpfreaks.com/topic/164693-how-to-fopen-a-site-that-requires-a-username-and-password/#findComment-868567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.