Skip to content

Instantly share code, notes, and snippets.

@paulund
Created June 25, 2013 18:39
Show Gist options
  • Save paulund/5861101 to your computer and use it in GitHub Desktop.
Save paulund/5861101 to your computer and use it in GitHub Desktop.
Here is an example of a CURL request using PHP.
<?php
$request = "request=string of request";
// Send using curl
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url); // URL to post
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); // headers from above
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PORT, 8080);
curl_setopt($ch, CURLOPT_POSTFIELDS,$request);
$result = curl_exec( $ch ); // runs the post
//perform tasks on $result
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment