1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | $url = 'https://api.xyz.com/api/register/'; $params = array( 'first_name' => $first_name, 'middle_name' => $middle_name, 'last_name' => $last_name, 'email' => $email, 'phone_number' => $phone_number, 'password' => $password, 'address' => $address, 'age' => $age, 'state' => $state, 'city' => $city, 'pincode' => $pincode, 'username' => $username ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $result = curl_exec($ch); if(curl_errno($ch) !== 0) { error_log('cURL error when connecting to ' . $url . ': ' . curl_error($ch)); } curl_close($ch); print_r($result); |