Jump to content

how to fopen a site that requires a username and password ?


bidntrade

Recommended Posts

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 ?

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

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.

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

 

 

 

 

 

 

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 :P

 

Read up on cURL.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.