<?php
#push_api_url //URL地址 POST方式
#post_data //数组
#var_export //返回值输出
// 指明给谁推送,为空表示向所有在线用户推送
// 推送的url地址,使用自己的服务器地址
$push_api_url = "http://192.168.2.47:2121/";
$json = '{"type":"publish","to":"2","content":"232342"}'; //使用JSON数据发送
$obj = json_decode($json);
$post_data = $obj;
//var_dump ($obj);
//exit;
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $push_api_url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
curl_setopt ($ch, CURLOPT_HTTPHEADER, array("Expect:"));
$return = curl_exec ( $ch );
curl_close ( $ch );
var_export($return);
//var_export ($post_data);
exit;
【收藏本页】 【返回顶部】 【关闭窗口】