Skip to content

Instantly share code, notes, and snippets.

@binwilly
Created February 11, 2015 02:14
Show Gist options
  • Save binwilly/d5da4f617a53c5eff161 to your computer and use it in GitHub Desktop.
Save binwilly/d5da4f617a53c5eff161 to your computer and use it in GitHub Desktop.
<?php
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$ch = curl_init('http://putsreq.com/4qyR3oP7gpnNXpoPPuh2');
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
var_dump($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment