fopen and cookies?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant

    fopen and cookies?

    Hi,

    I'm trying to use fopen to open a remote page. I found a page that
    doesn't work, and it's because the page requires cookies. Is there a
    way in PHP to pass cookies to a remote host?

    Here is my source test code:


    Code:

    <html><head><ti tle>fopen test</title></head>
    <body>
    <?


    $url = "http://www.bestbuy.com/";
    $f = fopen($url, 'r');
    if($f)
    {
    $page = "";
    while($pre = fread($f,100000 ))
    {
    $page = $page.$pre;
    }
    echo "Page:<br>$page <br><br>";
    }
    else
    {
    echo "Can't open page<br>";
    }

    ?>

    </body>
    </html>




    If you run the script, you are supposed to get the remote page
    displayed back. In this case I get an error message from Best Buy
    complaining that I must enable cookies to visit the site. How can I
    overcome this with PHP?

    Thanks,
    Grant
  • Tim Van Wassenhove

    #2
    Re: fopen and cookies?

    In article <fvgq90tj162civ grqnr9vlopn4rnj ua1mc@4ax.com>, Grant wrote:[color=blue]
    > I'm trying to use fopen to open a remote page. I found a page that
    > doesn't work, and it's because the page requires cookies. Is there a
    > way in PHP to pass cookies to a remote host?[/color]

    Have a look at the curl module. http://www.php.net/manual

    --

    Comment

    • Chung Leong

      #3
      Re: fopen and cookies?

      "Grant" <Grant@nospam.c om> wrote in message
      news:fvgq90tj16 2civgrqnr9vlopn 4rnjua1mc@4ax.c om...[color=blue]
      > Hi,
      >
      > I'm trying to use fopen to open a remote page. I found a page that
      > doesn't work, and it's because the page requires cookies. Is there a
      > way in PHP to pass cookies to a remote host?[/color]

      See http://www.php.net/manual/en/functio...ext-create.php


      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: fopen and cookies?

        Grant <Grant@nospam.c om> wrote in message news:<fvgq90tj1 62civgrqnr9vlop n4rnjua1mc@4ax. com>...[color=blue]
        > Hi,
        >
        > I'm trying to use fopen to open a remote page. I found a page that
        > doesn't work, and it's because the page requires cookies. Is there a
        > way in PHP to pass cookies to a remote host?[/color]

        <snip>

        1. http://in.php.net/curl
        2. http://curl.haxx.se/libcurl/php/exam...=cookiejar.php
        3. http://curl.haxx.se/libcurl/php/examples/

        --
        | Just another PHP saint |
        Email: rrjanbiah-at-Y!com

        Comment

        • Grant

          #5
          Re: fopen and cookies?

          On 11 May 2004 00:34:29 -0700, ng4rrjanbiah@re diffmail.com (R. Rajesh
          Jeba Anbiah) wrote:
          [color=blue]
          >Grant <Grant@nospam.c om> wrote in message news:<fvgq90tj1 62civgrqnr9vlop n4rnjua1mc@4ax. com>...[color=green]
          >> Hi,
          >>
          >> I'm trying to use fopen to open a remote page. I found a page that
          >> doesn't work, and it's because the page requires cookies. Is there a
          >> way in PHP to pass cookies to a remote host?[/color]
          >
          > <snip>
          >
          > 1. http://in.php.net/curl
          > 2. http://curl.haxx.se/libcurl/php/exam...=cookiejar.php
          > 3. http://curl.haxx.se/libcurl/php/examples/[/color]

          Hi, I finally got curl installed and compiled. Are there any more
          examples that might help me out? The page in question I'm trying to
          get is www.bestbuy.com . No matter what I do I can't get it to return
          the html contents. I think I'm getting hung up on the cookies.

          Any code would be much appreciated.

          Thanks,
          Grant

          Comment

          • R. Rajesh Jeba Anbiah

            #6
            Re: fopen and cookies?

            Grant <Grant@nospam.c om> wrote in message news:<ct12b05br q9bnhup866lg20i enbaoosrre@4ax. com>...
            <snip>
            [color=blue][color=green]
            > > 1. http://in.php.net/curl
            > > 2. http://curl.haxx.se/libcurl/php/exam...=cookiejar.php
            > > 3. http://curl.haxx.se/libcurl/php/examples/[/color]
            >
            > Hi, I finally got curl installed and compiled. Are there any more
            > examples that might help me out? The page in question I'm trying to
            > get is www.bestbuy.com . No matter what I do I can't get it to return
            > the html contents. I think I'm getting hung up on the cookies.[/color]

            Could you post your code, so that we can find what is wrong with your code/logic?

            --
            | Just another PHP saint |
            Email: rrjanbiah-at-Y!com

            Comment

            Working...