WordPress – 通过Server酱发送微信通知给微信
原创文章,作者:StubbornHuang,如若转载,请注明出处:《WordPress – 通过Server酱发送微信通知给微信》https://www.stubbornhuang.com/691/
1 Server酱官网
网址:http://sc.ftqq.com/3.version
进入Server官网使用GitHub账号密码申请secret key。
2 封装发送微信消息函数
在主题function.php中添加以下代码:
/* 通过Server酱(http://sc.ftqq.com/3.version)向个人微信客户端推送消息
text:消息标题
desp:消息内容
key:Server酱推送api secret key
*/
function SendMessageToWeChatByServerJiang( text ,desp = '' , key = '你自己的secret key' )
{postdata = http_build_query(
array(
'text' => text,
'desp' =>desp
)
);
opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' =>postdata
)
);
context = stream_context_create(opts);
return result = file_get_contents('https://sc.ftqq.com/'.key.'.send', false, $context);
}
3 使用方式
在自己需要使用通知函数的地方调用上述函数:
SendMessageToWeChatByServerJiang('新消息','Hello World');
当前分类随机文章推荐
- WordPress - get_post_type():获取当前文章或者给定文章类型
- WordPress - 利用Revolvermaps在首页实时显示访客3D地球
- WordPress - 添加网页三角网粒子背景 Canvas-nest.js
- WordPress - $Post WP_Post对象的属性
- WordPress - 后台登录成功/失败发送邮件给网站管理员
- WordPress - PhpStudy本地环境修改固定链接打不开网页404错误
- WordPress - 禁用XML-RPC接口,禁止访问xmlrpc.php,避免DDOS攻击,防止暴力破解
- WordPress - 下载安装插件失败,无法创建目录
- 网站个性化 - 添加人形时钟 honehone_clock.js
- WordPress - 插件WP Editor.md 在网站更换为https后无法正确加载
全站随机文章推荐
- C++ - std::map - 存储动态指针时正确释放内存
- 资源分享 - Computational Geometry in C(Joseph O'Rourke 1998)英文高清PDF下载
- WordPress - 插件WP Editor.md 在网站更换为https后无法正确加载
- OpenCV - 使用findContours()查找图片轮廓线,并将轮廓线坐标点输出
- 我的开源项目 - 各种搜索引擎收录查询接口(Google/百度/必应/360/搜狗......)
- Pac - Github Pac规则
- Centos7 - nohup方式优雅的部署jar包
- 资源分享 - GDI+教程(C++中文版 GDI+SDK中文参考手册)PDF下载
- Duilib - pos和padding属性设置的顺序
- 资源分享 - 解读基金:我的投资观与实践(季凯帆,康峰著)PDF下载