Skip to content

Instantly share code, notes, and snippets.

@piiskop
Last active March 14, 2018 09:24
Show Gist options
  • Save piiskop/eaf6bd6ee2ecf2131f234ecdf81976ec to your computer and use it in GitHub Desktop.
Save piiskop/eaf6bd6ee2ecf2131f234ecdf81976ec to your computer and use it in GitHub Desktop.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
// @formatter:off
$url = sprintf(
'http://%1$s:%2$u/study-groups?format=json',
$_SERVER['SERVER_NAME'], // 1
$_SERVER['SERVER_PORT'] // 2
);
// @formatter:on
$data = array (
'name' => 'TA31'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array (
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("Content-Type:application/json");
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment