Help with CURL please



I'm having a problem getting Curl to work properly...and I know its because of this unique situation, so I'm hoping a CURL expert can help me out.

I'm trying to access this URL (public search form) using CURL and grab the HTML contents
http://enterprisedirectory.ucr.edu/phone/tel_search.show

Now the problem is that in order to access that site, a Cookie must be set. For the web browser if you attempt to access the site, it redirects you to http://enterprisedirectory.ucr.edu, sets the cookie then sends you back. In PHP if I call curl on this site, instead of grabbing the contents it physically redirects the browser to http://enterprisedirectory.ucr.edu (thus leaving my script) and then back to the search page (still not in my script)

So im thinking the only way to do this is to use CURL, pass a cookie along with the CURL requests and then it will not do the redirect on me. Well the problem with that is when I view my cookies I can see the cookie that was set, but in my cookies.txt (or Cookie folder in IE) there is no record of this cookie!!??

So i tried doing this and creating a cookie file with the contents
enterprisedirectory.ucr.edu TRUE /phone/ TRUE 1181508361 SearchID 5851

Then in PHP use this
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT,120);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$results = curl_exec($ch);
curl_close($ch);

That did not work, but Im assuming I did it wrong. Can someone please help me out with this, I really need to get this working. After about 5 hours of this im pulling my hair out and begging for help.
Thank you
-Ray
.



Relevant Pages

  • Re: Automatic login to a web page
    ... This is mentioned in my isp login page "Cookies must be enabled" ... And with third example [using Curl] ... sub body_callb { ... If it sets a cookie, Curl can handle that too, but it gets more ...
    (comp.lang.perl.misc)
  • Re: [PHP] Help with CURL please
    ... I'm trying to access this URL using CURL and grab ... Now the problem is that in order to access that site, a Cookie must be ... redirects you to http://enterprisedirectory.ucr.edu, sets the cookie ... http://enterprisedirectory.ucr.edu (thus leaving my script) and then ...
    (php.general)
  • Re: CURL and $_SESSION problem
    ... >> the US Federal Government, and you know how the government is! ... > See the headers it sends to its clients (and to index.php CURL calls). ... Once I get the cookie then I ... I can get my own PHPSESSID but I can't get the REMOTE ...
    (comp.lang.php)
  • Re: Help to automatically traverse a login session
    ... Session and/or Cookie. ... Within this logged-in area, there are links ... Such "web scraping" can be done with cURL ... <?php echo 'Just another PHP saint'; ...
    (comp.lang.php)
  • Re: Help to automatically traverse a login session
    ... Session and/or Cookie. ... Within this logged-in area, there are links ... Such "web scraping" can be done with cURL ... <?php echo 'Just another PHP saint'; ...
    (comp.lang.php)