simply curl post request php, curl is an open source free command line platform as well as good library for some client side to server side transferring data with base URL. curl is a powerful useful system to transfer data to many types of the protocals. this is a good method to send data between your each websites.
cURL is unrestricted therefor it can be create easy step to call HTTP Request ,also create complex types of the FTP data upload with an authentication, also can create HTTPS requests.
Steps to create curl get post calls :
php cURL is free based web software which you can use to create various lots of the requests using different types of the protocols. PHP has the many option to use cURL and in this big post, i will learn to different examples like as a cURL POST header parameters file json request.
First argument $ch_curl
A php cURL simple and easy way to handle returned by curl_init().
Second argument is setting $option
The CURLOPT_XXX option to change or update.
Third And Last argument is $value
The data value to be update on option. for example. array or any value
following are the some main PHP CURL Request settings i can use inside curl_setopt() methods
1. CURLOPT_RETURNTRANSFER – update it TRUE to return the results as a data string, if not update this parameter then results will resultings on page then i can use file_get_contents(‘url’) to get results. Example : curl_setopt($ch_curl, CURLOPT_RETURNTRANSFER, true);
2. CURLOPT_CONNECTTIMEOUT – total Number of seconds to try to connect Example : curl_setopt($ch_curl, CURLOPT_CONNECTTIMEOUT, 60);
3. CURLOPT_URL – URL to sent curl request. Example : curl_setopt($ch_curl, CURLOPT_URL, “http://www.pakainfo.com”);
4. CURLOPT_POST – update when sending curl post request. Example : curl_setopt($ch_curl, CURLOPT_POST, true);
5. CURLOPT_POSTFIELDS – Array of data sent in post. Example : curl_setopt($ch_curl, CURLOPT_POST, array(“mobile_code” => “M150”, “mobile_price” => “158747”));
6. CURLOPT_TIMEOUT – Number of seconds cURL will take to execute. Example : curl_setopt($ch_curl, CURLOPT_TIMEOUT, 60);
7. CURLOPT_FRESH_CONNECT – Each curl call be refresh. Example : curl_setopt($ch_curl, CURLOPT_TIMEOUT, true);
8. CURLOPT_USERPWD – Some rest pages/api required secure more types of the authentication to access, for these cases i will use this setting. Example : curl_setopt($ch_curl, CURLOPT_USERPWD, “YOURUSERNAME:YOURPASSWORD”);
curl_exec() call will execute for curl settings as well as return results.
curl_close() will call to free all curl resources.
here simple PHP code to PHP GET/POST request articles learn how to generate as well as setp by step process GET and POST http requests in PHP. I use plain simple core PHP and Laravel and Symfony, Slim or any other frameworks.
The Hypertext Transfer Protocol (HTTP) is an application protocol for collaborative, distributed, hypermedia information systems. HTTP protocol is the foundation of data communication for the World Wide Web.
HTTP GET request
The HTTP GET request method http requests a step by step calling of the particluers resource.
have to only be used to http request a resource
arguments are displayed in the URL
can be cached
remain in the browser history
can be any types of the custom bookmarked
should never be used when dealing with any types of the sensitive data
have length limits
HTTP POST request
The HTTP POST http request method sends data to the server side. this is many times used when data uploading a file or when any types of the submitting a fully web form serverside. POST requests:
have to be used to make a resource
arguments are not displayed in the URL
are never any types of the cached
don’t remain in the browser history
cannot be any type of the bookmarked
can be used when dealing with any types of the sensitive data
have no any security length limits
I hope you get an idea about curl post request php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.