Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Created May 9, 2015 07:05
Show Gist options
  • Select an option

  • Save Darkflib/cb56f144c0a66ded9a59 to your computer and use it in GitHub Desktop.

Select an option

Save Darkflib/cb56f144c0a66ded9a59 to your computer and use it in GitHub Desktop.

Revisions

  1. Darkflib created this gist May 9, 2015.
    18 changes: 18 additions & 0 deletions pushstream.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    $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);