test.php 842 B

123456789101112131415161718192021222324
  1. <?php
  2. function push1($content,$to_user){
  3. $push_api_url = 'http://127.0.0.1:2121/';
  4. $data = [
  5. 'type' => 'publish',
  6. 'content' => $content,
  7. 'to' => $to_user,
  8. ];
  9. $ch = curl_init ();
  10. curl_setopt($ch, CURLOPT_URL, $push_api_url);
  11. curl_setopt($ch, CURLOPT_POST, 1);
  12. curl_setopt($ch, CURLOPT_HEADER, 0);
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  15. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
  16. $res = curl_exec($ch);
  17. curl_close($ch);
  18. var_dump($res);
  19. }
  20. $ss = '{"code": 0,"msg": "已应战,请准备开始对战!","data": {"record_id": "11","user_id": "1000005","ref_user_id": "1000010"}}';
  21. $ss = urlencode($ss);
  22. push1($ss,123);
  23. push1('测试1',123);