Skip to content

Instantly share code, notes, and snippets.

@djmeph
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djmeph/2d15046fe04ef66693cc to your computer and use it in GitHub Desktop.
Save djmeph/2d15046fe04ef66693cc to your computer and use it in GitHub Desktop.
function post($url,$data, $username, $password) {
$file = file_get_contents($data, true);
$process = curl_init();
curl_setopt($process, CURLOPT_URL, $url);
curl_setopt($process, CURLOPT_USERPWD, "$username:$password");
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_VERBOSE, false);
curl_setopt($process, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_POST, true);
curl_setopt($process, CURLOPT_POSTFIELDS, $file);
$return = curl_exec($process);
$header_size = curl_getinfo($process, CURLINFO_HEADER_SIZE);
$resposeheader = substr($return, 0, $header_size);
$resposebody = substr($return, $header_size);
curl_close($process);
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment