Skip to content

Instantly share code, notes, and snippets.

Created June 1, 2017 17:24
Show Gist options
  • Save anonymous/adc6c380c08d9eeb937e3279fca303fb to your computer and use it in GitHub Desktop.
Save anonymous/adc6c380c08d9eeb937e3279fca303fb to your computer and use it in GitHub Desktop.
function post($url, $data, $cookies = null, $headers = false)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_HEADER, $headers);
curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded' ]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment