$id='1227feacf41c472e5ee34e20b510a240ad81ea6e'; echo 'id '.$id."\n"; $url = 'http://example.com/activity/pub?id='.$id; echo 'url '.$url."\n"; $data = array( 'foo' => 'bar' ); $data_json = json_encode($data); echo $data_json."\n"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json))); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch);