PHP cURL tutorial

cbnoob

Senior Member
Joined
Sep 27, 2010
Messages
969
Reaction score
463
Hey PHP guys,

I'm learning cURL in php now but there was not many good tutorial or book on this. I've just grabbed a book, written by phptrack. It's the only book available about this topic I can find. I think some of you guys may finding the same stuff. Hope it helps somehow.

Download
Code:
http://www.mediafire.com/?dj961s32t7gahaq

VT

Code:
http://www.virustotal.com/file-scan/report.html?id=66e5305cb4cec10f8d08a1cc72597eb90f3af9b0d5ab98c883df5165903a6575-1323538361
File name:
PHP cURL.zip
Submission date:
2011-12-10 17:32:41 (UTC)
Current status:
finished
Result:
1/ 42 (2.4%)
 
Being a PHP developer who often uses cURL, it's a pretty good read, especially for someone who's just starting out with PHP/cURL, and needs a guide to run them through step-by-step cURL usage, from retrieving a basic page to sending data via the the HTTP POST method to adding additional cURL options, such as setting a user agent or referrer.
 
Thread moved to the PHP/PERL section.

"Wiz"
 
does it write how to receive captcha and send answer back to page?
 
does it write how to receive captcha and send answer back to page?

Every captcha is different. But even recaptcha is easy once you get the hang of it.
(You just have to parse the javascript, and follow what your browser would do).
 
For newbies to CURL:
One thing the PDF fails to mention is detecting CURL errors. More often than not, if you do not handle CURL errors you can be sitting there scratching your head for a long time wondering why the hell no content is being returned. A simple way to detect CURL erros is by adding an error detection to the CURL handler:
$err = curl_errno($ch);

This will return a number, you can store common errors in your code to return the error or look them up here:
http://curl.haxx.se/libcurl/c/libcurl-errors.html

This can save a lot of time and hassle when using CURL with sites like Twitter who return a lot of Not Allowed requests when you are posting content using an incorrect content-type.
 
This is great. Im' planning to do http post request.
What is the difference between using cUrl and native PHP functions?
 
This is great. Im' planning to do http post request.
What is the difference between using cUrl and native PHP functions?

you can do a lot with curl that you wouldn't otherwise be able to do (to my knowledge)
i.e. fake a referrer, user agent, multi threading, etc.
 
you can do a lot with curl that you wouldn't otherwise be able to do (to my knowledge)
i.e. fake a referrer, user agent, multi threading, etc.
so, it's more sutable for blackhat stuff,

and what about PECL, it too has similar things?
 
Thanks, but I want to ask, curl looping application capable of how long the process in memory
:D
 
Great share OP!
I was looking for a tutorial on cURL and big G brought me here :D
 
Hey PHP guys,

I'm learning cURL in php now but there was not many good tutorial or book on this. I've just grabbed a book, written by phptrack. It's the only book available about this topic I can find. I think some of you guys may finding the same stuff. Hope it helps somehow.

Boy is this timley! I've been doing some cURL with proxy's, referrers, cookies and user agents and following examples in the cURL documentation that say's turn headers ON, no turn Headers OFF, same with CURLOPT_FOLLOWLOCATION , CURLOPT_AUTOREFERER , CURLOPT_RETURNTRANSFER , CURLOPT_FRESH_CONNECT, CURLOPT_FORBID_REUSE - my head is spinning!

My code works - much of the time, but big G catches on to me pretty quickly and gives me a CAPTCHA page with the message - Our systems have detected unusual traffic from your computer network. This page checks to see if it's really you sending the requests and not a robot. - Of course the code is a bot, but I was expecting cURL to help.

A quick look at the pdf - especially the section on debugging looks especially promising.

Of course, if anyone has any pointers to examples that really work I'd welcome them.
 
Last edited:
Cheers for the share mate,

took one look at curl before and it scared me with all the different functions, and lack of indepth online tutorial.

Shall take a flick through
 
I'm no noob to cURL, but there is certainly a lack of *useful* cURL information out there for bot makers. Definitely recommend checking this one out :D
 
php simply grabs website content to be analyzed. curl also does this however it can also post forms, log into accounts, and help disguise your requests to help stay off the radar

This is great. Im' planning to do http post request.
What is the difference between using cUrl and native PHP functions?
 
Back
Top