PHP CURL POST & GET Examples – Submit Form using PHP CURL

Sourabh Jain

In PHP CURL POST tutorial, I have explained how to send HTTP GET / POST requests with PHP CURL library.

Below are the examples covered in this article.
1) Send HTTP GET Request with CURL
2) Send HTTP POST Requests with CURL
3) Send Random User-Agent in the Requests
4) Handle redirects (HTTP 301,302)
5) Handle Errors.

Why we need PHP CURL ?
To send HTTP GET requests, simply we can use file_get_contents() method.


But sending POST request and handling errors are not easy with file_get_contents().

Sending HTTP requests is very simple with PHP CURL.You need to follow the four steps to send request.

step 1). Initialize CURL session

$ch= curl_init();

step 2). Provide options for the CURL session

//curl_setopt($ch,CURLOPT_HEADER, true); //if you want headers


Ver la entrada original 619 palabras más

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s