SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question accessing password protected files on remote servers

    i want to make a script that automatically grabs my AWS reports from associates.amazon.com using PHP. the only problem is that the reports are password protected. how do i grab a page that is password protected and is not on my server?

    thanks

  2. #2
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming an http header call is not required, have you tried something like:
    PHP Code:
    file_get_contents("http://user:password@amazon.com/path"
    ?

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's currently down it appeares, though as I recall it's their own form, and I'd assume it's HTTPS. You'll need to send the HTTP request manually, and probably using cURL too. It's not just uesrassword@amazon, though. That's for HTTP authentication only (which is really low level, nobody uses that).

  4. #4
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by someonewhois
    That's for HTTP authentication only (which is really low level, nobody uses that).
    You'd be surprised- A lot of places still do use only http authentication.

    Quote Originally Posted by someonewhois
    probably using cURL
    I was going to suggest cURL next, if his host supported it

    Quote Originally Posted by someonewhois
    It's not just uesr:password@amazon, though.
    Sometimes BBcode parsing can be pretty humorous

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thanks for the replies,

    ya it appears they are down...so i cant test anything.

    my server does support cURL, though i have no earthly idea how to use it.

    also that is an affirmative on the HTTPS.

    thanks,
    blayne

    edit: i have decided to do this same thing with my adsense reports, which is also HTTPS (same concept though, rite?)

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all try just file_get_contents("https://host"). If you have luck and you php is compiled with SSL, you can get along without curl.

  7. #7
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, AdSense would be the same concept. Just need to look at the form and figure out what post headers to send.

  8. #8
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whenever i do what you said, i just get the login page

    i was thinking this is because either a) its https, or b) there is an '@' sign in my username.

    i tried using %40, @, and @, instead of the '@' sign, and none of them got me anything but the login page

    that was on the amazon page

    but on the adsense page, i did it and i got an error

    Code:
    Warning: file_get_contents(): SSL: fatal protocol error in /home/pcbunk/public_html/deletethis.php on line 2
    thats if i replace '@' with '%40' or '@' with '@'.

    i have no idea how to do curl or send post headers, could someone help me out here?

    Thanks,
    Blayne
    Last edited by XtrEM3; Feb 2, 2005 at 16:01. Reason: parsing html entities wrong

  9. #9
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i saw u mentioned it'd work if my "php is compiled with SSL"...i know my host supports SSL, would that help or is that a different thing?

    edit: i just decided to learn cURL...i got it working now...both Adsense and aws Reports.

    if any1 is interested in generating reports for AWS or Adsense, check out this script

    Thanks,
    Blayne
    Last edited by XtrEM3; Feb 2, 2005 at 22:10.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •