
This is a discussion on PHP CURL/LIBCURL Login/Post within the PHP forums, part of the Program Your Site category; I needed something much more robust than the standard way of using curl, and i also wanted to be able ...
| |||||||
| 152 Online | Register | Projects | Products | Members List | Calendar | Today's Posts | Search |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PHP CURL/LIBCURL Login/Post I needed something much more robust than the standard way of using curl, and i also wanted to be able to easily make calls. POST requests with curl require two things to be set: CURLOPT_POST, CURLOPT_POSTFIELDS but theres also one param that may also be need to be true (this lets your server follow where the site tells it to go): CURLOPT_FOLLOWLOCATION and if you wanted to use cookies you would need to set these two too: CURLOPT_COOKIEJAR (for writing), CURLOPT_COOKIEFILE (for reading) I usually spoof a browser useragent too: CURLOPT_USERAGENT here is the sexy function :) PHP Code: PHP Code: we dont want to set CURLOPT_RETURNTRANSFER. Our next request would theroetically request google.com after it was logged in with "foo:bar" PHP Code: The following is all you need to know about all the options, its a great reference :)
|
![]() |
| |
| ||||
| Posted By | For | Type | Date | |
| Digg - PHP CURL/LIBCURL Tutorial | This thread | Refback | 02-27-2009 02:41 PM | |