Skip to content

Instantly share code, notes, and snippets.

@okiwan
Created May 22, 2014 07:51
Show Gist options
  • Save okiwan/5d5fb13cc616ae83e095 to your computer and use it in GitHub Desktop.
Save okiwan/5d5fb13cc616ae83e095 to your computer and use it in GitHub Desktop.
POST request with PHP Curl
<?php
$data = file_get_contents('/Users/socana/Desktop/request.txt');
$rsc = curl_init();
curl_setopt($rsc, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($rsc, CURLOPT_URL, "http://demo.optimizr.eu:8080/OptimizrAnalysis/analyze");
curl_setopt($rsc, CURLOPT_POST, true);
curl_setopt($rsc, CURLOPT_POSTFIELDS, $data);
curl_setopt($rsc, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($rsc);
curl_close($rsc);
print_r(json_decode($result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment