.htaccess password auth but allow post request
Here is a example function of how to achieve this.
function curl_bounce_server( $url, $param ){ try { $ch = curl_init(); $username = "your_user"; $password = "your_pass"; // set URL and other appropriate options curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_POST, 1 ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT, 30 ); curl_setopt( $ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ); curl_setopt( $ch, CURLOPT_POSTFIELDS, 'json='. $param ); $response = curl_exec( $ch ); curl_close($ch); return $response; } catch ( Exception $exception ) { return "An exception occurred when executing the server call - exception:" . $exception->getMessage(); }}