Apicloud的云推送api, php版
class ApicloudPush
{
public static $api = 'https://p.apicloud.com/api/push/message';
public static $appid = 'A6920463******';
public static $appkey = 'C******8-B6BB-3027-2C93-6C********29';
public static function post($post_data)
{
$appkey = sha1(self::$appid . "UZ" . self::$appkey . "UZ" . time()) . "." . time();
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_HTTPHEADER, [
'X-APICloud-AppId:'. self::$appid,
'X-APICloud-AppKey:' . $appkey
]);
curl_setopt($ch, CURLOPT_POST, count($post_data));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, self::$api);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
ob_start ();
curl_exec ($ch);
$result = ob_get_contents ();
ob_end_clean();
curl_close ($ch);
return $result;
}
}
$title = isset($_GET['title']) ? $_GET['title'] : '测试标题';
$content = isset($_GET['content']) ? $_GET['content'] : '测试内容';
var_dump(ApicloudPush::post([
'title' => $title,
'content' => $content,
'type' => 2, //– 消息类型,1:消息 2:通知
'platform' => 0, //0:全部平台,1:ios, 2:android
// 'groupName' => 'department', //推送组名,多个组用英文逗号隔开.默认:全部组。eg.group1,group2 .
// 'userIds' => 'shuai' //推送用户id, 多个用户用英文逗号分隔,eg. user1,user2。
]));
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续努力!