Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl -X POST http://192.168.1.101:8000/faye -H 'Content-Type:
- application/json' -d '{"channel":"/foo","data":{"hello":"world"}}'
- $data = array("channel" => "/one", "result" => "Hello World from PHP!!");
- $data_string=json_encode($data);
- $ch = curl_init('http://192.168.1.101:8000/faye');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
- curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_HTTPHEADER,array(
- 'Content-Type:application/json','Content-Length:'strlen($data_string)));
- $result = curl_exec($ch);
- var publication = client.publish('/one',{ result: 'Hello World from JS'});<br/>
- $data = array("channel" => "/one", "data" => array ("result"=>"HelloWorld from PHP!!"));
- $data_string=json_encode($data);
- $ch = curl_init('http://localhost:8000/faye');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
- curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type:application/json'));
- echo $result = curl_exec($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement