I’m using the following simple PHP script to make post requests. If you need to upload a file instead, check my article: “upload a file with cURL”.
<?php function postRequest($url, $curl_data) { $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 9, CURLOPT_TIMEOUT => 15, CURLOPT_MAXREDIRS => 3, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $curl_data, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_VERBOSE => 1, CURLOPT_PROXY => null // if using a proxy, use the syntax "proxyuser:proxypass@proxyurl:proxyport" ); $ch = curl_init($url); curl_setopt_array($ch, $options); $content = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch) ; $header = curl_getinfo($ch); curl_close($ch); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } echo print_r(postRequest("http://targeturl.com", "fieldA=valueA&fieldB=valueB"), true); ?>