curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET' ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );<?php $post = [ 'username' => 'user1', 'password' => 'passuser1', 'gender' => 1, ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.domain.com'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); $response = curl_exec($ch); var_export($response); private function callApi($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); return json_decode($result); }// set post fields $post = [ 'username' => 'user1', 'password' => 'passuser1', 'gender' => 1, ]; $ch = curl_init('http://www.example.com'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // execute! $response = curl_exec($ch); // close the connection, release resources used curl_close($ch); // do anything you want with your response var_dump($response);function getUrl($url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($ch); curl_close($ch); return $response; } <?php // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ?>function &web_curl_http($url) { $c = curl_init(); curl_setopt( $c , CURLOPT_URL , $url); curl_setopt( $c , CURLOPT_USERAGENT, "Mozilla/5.0 (Linux Centos 7;) Chrome/74.0.3729.169 Safari/537.36"); curl_setopt( $c , CURLOPT_RETURNTRANSFER, true); curl_setopt( $c , CURLOPT_SSL_VERIFYPEER, false); curl_setopt( $c , CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $c , CURLOPT_TIMEOUT, 10000); // 10 sec $data = curl_exec($c); curl_close($c); return $data; }<?php // From URL to get webpage contents $url = "https://www.geeksforgeeks.org/"; // Initialize a CURL session. $ch = curl_init(); // Return Page contents. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Grab URL and pass it to the variable curl_setopt($ch, CURLOPT_URL, $url); $result = curl_exec($ch); echo $result; ?>$ch = curl_init(); $curlConfig = array( CURLOPT_URL => "http://www.example.com/yourscript.php", CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => array( 'field1' => 'some date', 'field2' => 'some other data', ) ); curl_setopt_array($ch, $curlConfig); $result = curl_exec($ch); curl_close($ch); // result sent by the remote server is in $result $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); $result = curl_exec($ch); curl_close($ch); //check the result var_dump($result);