Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. curl -X POST http://192.168.1.101:8000/faye -H 'Content-Type:
  2. application/json' -d '{"channel":"/foo","data":{"hello":"world"}}'
  3.  
  4. $data = array("channel" => "/one", "result" => "Hello World from PHP!!");
  5. $data_string=json_encode($data);
  6. $ch = curl_init('http://192.168.1.101:8000/faye');
  7. curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
  8. curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
  9. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  10. curl_setopt($ch,CURLOPT_HTTPHEADER,array(
  11. 'Content-Type:application/json','Content-Length:'strlen($data_string)));
  12. $result = curl_exec($ch);
  13.  
  14. var publication = client.publish('/one',{ result: 'Hello World from JS'});<br/>
  15.  
  16. $data = array("channel" => "/one", "data" => array ("result"=>"HelloWorld from PHP!!"));
  17. $data_string=json_encode($data);
  18. $ch = curl_init('http://localhost:8000/faye');
  19. curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
  20. curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
  21. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  22. curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type:application/json'));
  23. echo $result = curl_exec($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement