PHP语言
提示
由于GET请求只需在url上拼接head和body参数太简单了, 很多编程语言只需一句,例如php:
<?php echo file_get_contents("https://www.phprm.com/services/push/trigger/4d2dac865118761a14d10d7d3afe7c35?head=".urlencode("这是标题")."&body=".urlencode("这是长内容")); ?>
1
<?php
// 通道码/口令码
$channel_code = "4d2dac865118761a14d10d7d3afe7c35";
$head = "测试标题";
$body = "测试内容";
// 可选,不跳转到url地址可不传
$body = "http://push.phprm.com/";
$postdata = json_encode(
array(
'head' => $head,
'body' => $body,
'url' => $url
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/json;charset=UTF-8',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$api_url = 'https://www.phprm.com/services/push/trigger/'.$channel_code;
$result = file_get_contents($api_url, false, $context);
echo $result;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
如果你更倾向于使用curl库, 完全可以自己实现或者参考以下开源的三方库里的curl代码。
# 一些开源的三方库
- 如果希望使用专业推送库, 可以参考此开源项目, 【一封传话】聚合推送SDK已经提交到Github和Gitee,通过composer可以直接安装SDK:
Github: https://github.com/guanguans/notify (opens new window)
Gitee: https://gitee.com/guanguans/notify (opens new window)
- 提供博客系统新注册用户、新评论提醒插件, 可以参考插件源码或者直接在自己的网站使用:
WordPress插件: https://github.com/teakong/wordpress-tixing (opens new window) 或者 https://gitee.com/teakong/wordpress-tixing (opens new window)
Typecho插件: https://github.com/teakong/TypechoTixing (opens new window) 或者 https://gitee.com/teakong/TypechoTixing (opens new window)
其他博客或网站插件: https://github.com/teakong/liuyan-weixin (opens new window) 或者 https://gitee.com/teakong/liuyan-weixin (opens new window)
Last Updated: 2024/12/12, 21:28:26