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 ?

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.