摘要:本文将带你了解微信开发zabbix调用微信接口报警,希望本文对大家学微信有所帮助。
本文将带你了解微信开发zabbix调用微信接口报警,希望本文对大家学微信有所帮助。
"
1.下载微信接口
git clone https://github.com/lealife/WeiXin-Private-API
将微信接口移动至zabbix默认脚本路径
zabbix默认脚本路径:/usr/lib/zabbix/alertscripts/
[root@zabbix alertscripts]# vim WeiXin-Private-API/config.php
// 全局配置
$G_ROOT = dirname(__FILE__);
$G_CONFIG[""weiXin""] = array(
'account' => '3133187148@qq.com', ###微信公众账号
'password' => '微信公众账号密码',
'cookiePath' => $G_ROOT. '/cache/cookie', // cookie缓存文件路径
'webTokenPath' => $G_ROOT. '/cache/webToken', // webToken缓存文件路径
);
[root@zabbix alertscripts]# vim WeiXin-Private-API/test.php
require ""config.php"";
require ""include/WeiXin.php"";
$weiXin = new WeiXin($G_CONFIG['weiXin']);
#$testFakeId = ""oIzQiwod4i3VoLqTB5cgTQUUz76s"";
$testFakeId = ""$argv[1]"";
$msg=""$argv[3]"";
#print_r($weiXin->send($testFakeId, ""test""));
echo ""
"";print_r($weiXin->send($testFakeId, ""$msg""));
[root@zabbix alertscripts]# pwd
/usr/lib/zabbix/alertscripts
[root@zabbix alertscripts]# vim weixin.sh
/usr/bin/php /usr/lib/zabbix/alertscripts/WeiXin-Private-API/test.php ""$1"" ""$2"" ""$3""
进行测试
[root@zabbix alertscripts]# /usr/lib/zabbix/alertscripts/weixin.sh ""oIzQiwod4i3VoLqTB5cgTQUUz76s"" """" ""hi""
stdClass Object
(
[base_resp] => stdClass Object
(
[ret] => 0
[err_msg] => ok
)
)
测试成功!
!!!注意:若遇到以下情况,清除缓存
stdClass Object
(
[base_resp] => stdClass Object
(
[ret] => 200003
[err_msg] => invalid session
)
)
[root@zabbix alertscripts]# cd WeiXin-Private-API/
[root@zabbix WeiXin-Private-API]# ls
cache config.php include README.md test.php
[root@zabbix WeiXin-Private-API]# cd cache/
[root@zabbix cache]# ls
cookie webToken
[root@zabbix cache]# rm -fr *
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之微信频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号