cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: curl-and-php Digest, Vol 10, Issue 4

From: Tim Parkin <tparkin_at_gmail.com>
Date: Mon, 5 Jun 2006 14:41:32 -0400

Thanks for the replies guys. I have read/write permissions, in fact,
while testing I even chmod'ed the folder and files (including
cookie.txt) to 777! If I delete the cookie.txt file it gets created
and written to after the execution of the script. So I don't think
it's a permissions problem. I'm really starting to believe it's a
case that this version of curl can't handle.

I would greatly appreciate if anyone could spend 5-10 minutes and just
give it a try. Here's the latest code I tried. From this you can see
the page I'm trying to get to, and the referer it needs. Again, this
code WORKS (returns the correct search page) on the new(er) version of
curl but does NOT work on libcurl 7.10.6

<?php

        $ch = curl_init( );

        curl_setopt( $ch, CURLOPT_URL,

"https://sahr.cc.ucf.edu/servlets/iclientservlet/heprod/?ICType=Panel&Menu=SA_LEARNER_SERVICES&Market=GBL&PanelGroupName=CLASS_SEARCH&RL

=&target=main0&navc=0&adss=true&" );
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt( $ch, CURLOPT_AUTOREFERER, 1 );
        curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
        curl_setopt( $ch, CURLOPT_FRESH_CONNECT, 1 );
        curl_setopt( $ch, CURLOPT_HEADER, 1 );
        curl_setopt( $ch, CURLOPT_REFERER, "https://my.ucf.edu/index.html" );
        curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)" );
        curl_setopt( $ch, CURLOPT_COOKIEJAR, "./cookie.txt" );
        curl_setopt( $ch, CURLOPT_COOKIEFILE, "./cookie.txt" );
        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
        curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
        curl_setopt( $ch, CURLOPT_SSLVERSION, 3 );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 120 );
        curl_setopt( $ch, CURLOPT_TIMEOUT, 120 );

        curl_setopt( $ch, CURLOPT_VERBOSE, 1 );

        echo curl_exec( $ch );
        echo curl_exec( $ch );

        curl_close( $ch );

?>

Also, I understand that finding this version of libcurl (7.10.6) may
be difficult. Since I'm desperate to get this working on this
version, here's an ftp account on my hosting that you can use for
testing.

ftp://ftp.timparkin.com
username: curltest
password: curl123

You can access this from the web (to test) at this link:
http://timparkin.com/curl/

Or you can see my previous message (quoted below) for the explanation
and link to my last attempt's code that works on the new(er) version
of curl.

Any and all help is greatly appreciated! Thanks!

On 6/5/06, curl-and-php-request_at_cool.haxx.se
<curl-and-php-request_at_cool.haxx.se> wrote:
> Send curl-and-php mailing list submissions to
> curl-and-php_at_cool.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> or, via email, send a message with subject or body 'help' to
> curl-and-php-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> curl-and-php-owner_at_cool.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of curl-and-php digest..."
>
>
> Today's Topics:
>
> 1. cURL Cookie Trouble - Need Help! (Tim Parkin)
> 2. Re: cURL Cookie Trouble - Need Help! (tedd)
> 3. libcurl with redirects not working for google video, works
> with curl (Tim Schwartz)
> 4. Re: cURL Cookie Trouble - Need Help! (Mikael Gr?n)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 4 Jun 2006 12:43:40 -0700
> From: "Tim Parkin" <tparkin_at_gmail.com>
> Subject: cURL Cookie Trouble - Need Help!
> To: curl-and-php_at_cool.haxx.se
> Message-ID:
> <69ccbe340606041243x665cb879mf4a4e5cac9488064_at_mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi,
>
> I'm writing a PHP script to access a website via SSL using cURL. It
> works fine on my local machine, but when I try it on my shared hosting
> account it doesn't behave the same.
>
> First, the page I'm trying to access gives a 302 which is no big deal.
> cURL then follows the 302 without problem. The trouble starts here,
> when cURL goes to write the cookie. On my local machine cURL writes
> the cookie in full, however, on my shared hosting the cookie does not
> have the same variables/values and thus causes the page to give an
> error since it requires cookies.
>
> Another example that illustrates the problem is that if I run the
> script on my local machine, it works. Then if I take the cookie file
> it generated and put it on my shared hosting, the script will also
> work there. So obviously it's a problem with the cooke not being
> written correctly or something involving the cookie.
>
> At first I thought this was my fault (and perhaps it is!) but as I
> spend more time on it I'm starting to think it might be caused by the
> way my shared hosting server is setup or their version of cURL.
> Here's a comparison of cURL versions between my local machine and my
> shared hosting:
>
> Local Machine: CURL Information libcurl/7.14.0 OpenSSL/0.9.8a zlib/1.2.3
> Shared Hosting: CURL Information libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.1.4
>
> Also, here's a link to the PHP page on my shared hosting server so
> that you can see the Peoplesoft Error I get due to not having the
> right variables set in the cookie:
> http://www.collegeclasses.org/Schools/test2.php
> And the source of that page can be viewed here:
> http://www.collegeclasses.org/Schools/test2.php.txt
>
> The output of the PHP code from my local machine can be found at:
> http://www.collegeclasses.org/Schools/local.txt
> The output of the PHP code from my shared hosting can be found at:
> http://www.collegeclasses.org/Schools/shared.txt
>
> I mention this because if you look at the headers you can see the
> differences, and it's interesting to see how on the shared hosting the
> redirect from the 302 doesn't work correctly (again, I'm pretty sure
> it's because of the cookie problem).
>
> Any help is greatly appreciated. I've been struggling with this for
> too many hours. many hours.
>
> Thanks!
>
> --
> Tim Parkin
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 4 Jun 2006 16:09:44 -0400
> From: tedd <tedd_at_sperling.com>
> Subject: Re: cURL Cookie Trouble - Need Help!
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Message-ID: <p06230905c0a8ee56dece@[192.168.1.101]>
> Content-Type: text/plain; charset="us-ascii"
>
> >Any help is greatly appreciated. I've been struggling with this for
> >too many hours. many hours.
> >
> >Thanks!
> >
> >--
> >Tim Parkin
>
> Can you write/read anything?
>
> tedd
> --
> ------------------------------------------------------------------------------------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 4 Jun 2006 20:55:12 -0400
> From: "Tim Schwartz" <timatron_at_gmail.com>
> Subject: libcurl with redirects not working for google video, works
> with curl
> To: curl-and-php_at_cool.haxx.se
> Message-ID:
> <d75fb1970606041755o6c13163dub9a145b1ddf1c708_at_mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello all,
>
> I've been trying to use libcurl in php to download the actual flv files from
> google video, i can get it to work quite easily with the command line tool,
> but with libcurl in php it dont work none:( any ideas?
>
> if you open the url in firefox it will downlaod it.
>
> thx!
> -tim
>
> Example:
>
> this doesnt work -->
>
> <?php
>
>
> $url http://vp.video.google.com/videodownload?version=0&secureurl=tAAAAG7ggqAHSiJjpW0D3w4aYTWMt8S_dC2375mvvA8BjcduktxqIrT1TDF0HVE8bMJAdlIcqXmD9ObiGuRECCtbh-0mK8t-CmJG_YY52J9PQrZpomgh-WN_YOFz2yhmRDzUNFGiyu-O7lzYzyzspOX6vrf5qwmwNwW5udIplPwm-1CyiO5hiXtcw0FSxhzciEU3kEHUk5pNkh8TtmD0xjOHLT5elw9oh0HL4MVwd6PloHIDLZ4E6fGWfHqimwxWBtJxnQ&sigh=LDVIawBhi0Yh7-x_bkLfGwEFoNM&begin=0&len&5099&docid=-8627390594491892243
> ";
>
>
>
> $ch
>
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
> $data print_r(curl_getinfo($ch));
> curl_close($ch);
>
> echo $data;
>
> ?>
>
>
> this works -->
>
> curl -L "
> http://vp.video.google.com/videodownload?version=0&secureurl=tAAAAG7ggqAHSiJjpW0D3w4aYTWMt8S_dC2375mvvA8BjcduktxqIrT1TDF0HVE8bMJAdlIcqXmD9ObiGuRECCtbh-0mK8t-CmJG_YY52J9PQrZpomgh-WN_YOFz2yhmRDzUNFGiyu-O7lzYzyzspOX6vrf5qwmwNwW5udIplPwm-1CyiO5hiXtcw0FSxhzciEU3kEHUk5pNkh8TtmD0xjOHLT5elw9oh0HL4MVwd6PloHIDLZ4E6fGWfHqimwxWBtJxnQ&sigh=LDVIawBhi0Yh7-x_bkLfGwEFoNM&begin=0&len&5099&docid=-8627390594491892243
> "
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://cool.haxx.se/pipermail/curl-and-php/attachments/20060604/55cd9351/attachment.html
>
> ------------------------------
>
> Message: 4
> Date: Mon, 05 Jun 2006 07:59:47 +0200
> From: Mikael Gr?n <php_at_emgee.se>
> Subject: Re: cURL Cookie Trouble - Need Help!
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Message-ID: <4483C853.8020208_at_emgee.se>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Do you have administrator/root access to that host? In that case,
> upgrade cURL.
> Otherways, get the older version of cURL to your localhost and start
> working on getting it running there!
> If it's not, tedd suggests, a matter of privileges.
>
> Mikael
>
>
> Tim Parkin skrev:
> > Hi,
> >
> > I'm writing a PHP script to access a website via SSL using cURL. It
> > works fine on my local machine, but when I try it on my shared hosting
> > account it doesn't behave the same.
> >
> > First, the page I'm trying to access gives a 302 which is no big deal.
> > cURL then follows the 302 without problem. The trouble starts here,
> > when cURL goes to write the cookie. On my local machine cURL writes
> > the cookie in full, however, on my shared hosting the cookie does not
> > have the same variables/values and thus causes the page to give an
> > error since it requires cookies.
> >
> > Another example that illustrates the problem is that if I run the
> > script on my local machine, it works. Then if I take the cookie file
> > it generated and put it on my shared hosting, the script will also
> > work there. So obviously it's a problem with the cooke not being
> > written correctly or something involving the cookie.
> >
> > At first I thought this was my fault (and perhaps it is!) but as I
> > spend more time on it I'm starting to think it might be caused by the
> > way my shared hosting server is setup or their version of cURL.
> > Here's a comparison of cURL versions between my local machine and my
> > shared hosting:
> >
> > Local Machine: CURL Information libcurl/7.14.0 OpenSSL/0.9.8a zlib/1.2.3
> > Shared Hosting: CURL Information libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.1.4
> >
> > Also, here's a link to the PHP page on my shared hosting server so
> > that you can see the Peoplesoft Error I get due to not having the
> > right variables set in the cookie:
> > http://www.collegeclasses.org/Schools/test2.php
> > And the source of that page can be viewed here:
> > http://www.collegeclasses.org/Schools/test2.php.txt
> >
> > The output of the PHP code from my local machine can be found at:
> > http://www.collegeclasses.org/Schools/local.txt
> > The output of the PHP code from my shared hosting can be found at:
> > http://www.collegeclasses.org/Schools/shared.txt
> >
> > I mention this because if you look at the headers you can see the
> > differences, and it's interesting to see how on the shared hosting the
> > redirect from the 302 doesn't work correctly (again, I'm pretty sure
> > it's because of the cookie problem).
> >
> > Any help is greatly appreciated. I've been struggling with this for
> > too many hours. many hours.
> >
> > Thanks!
> >
> >
>
>
>
> ------------------------------
>
> _______________________________________________
> curl-and-php mailing list
> curl-and-php_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
> End of curl-and-php Digest, Vol 10, Issue 4
> *******************************************
>

-- 
Tim Parkin
tparkin_at_gmail.com
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-06-05