Help with CURL please!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux