【源码分享】抖音超火的微信推送消息~
标签搜索

【源码分享】抖音超火的微信推送消息~

Mrfly
2022-08-24 / 0 评论 / 112 阅读 / 正在检测是否收录...

使用方法:下载本文附件三个文件,自行注册微信测试平台账号并在后台配置好信息,填好下方模板消息,请需要接收消息的人扫码获取他的微信号,填写config以及index两个PHP文件中的信息后上传至服务器,访问index.php即可。如需定时发送可使用堡塔的计划任务。

微信接口测试平台模板

{{date.DATA}}
地区:{{region.DATA}}
天气:{{weather.DATA}}
气温:{{temp.DATA}}
风向:{{wind_dir.DATA}}
今天是我们恋爱的第{{love_day.DATA}}天
{{birthday1.DATA}}
{{birthday2.DATA}}

{{yiyan.DATA}}

以上如有不需要的文字内容可自行删除,如图

80c20ac9e6b81af4a04cca45e6a8bce.jpg

<?php
/** 开启 Session 配置 */
session_start();
require 'function.php';

/* 微信公众号信息配置 */
$WXconfig=array(
    'app_id' => '', //公众号appId
    'app_secret' => '', //公众号appSecret
    'template_id' => '', //模板消息id
    'user' => array('') //接收公众号消息的微信号【测试号用户列表中查看】,如果有多个,需要在()里用英文逗号间隔,例如('甲','乙')
);

/* 信息配置 */
$INFOconfig=array(
    'region' => '青浦区', //所在地区,可为城市,区,县,同时支持国外城市,例如伦敦
    'birthday1' => array('name'=>'','birthday'=>''), //修改名字为对应需要显示的名字,生日为公历哦~ 格式:2022-8-3
    'birthday2' => array('name'=>'','birthday'=>''), //同上
    'love_date'=>'', //同上
);

<?php
require './config.php';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$WXconfig['app_id']."&secret=".$WXconfig['app_secret'];
$returnJson = json_decode(Request_curl($url,''),true);
$token = $returnJson["access_token"];
if(!$token){
    $return = array(
        "code"=> $returnJson['errcode'],
        "msg"=> "获取access_token失败,请检查app_id和app_secret是否正确",
    );
    exit(Json($return));
}

$lunar=new Lunar();
$today=$lunar->convertSolarToLunar(date(Y),date(m),date(d));
$month=$lunar->getJieQi(date(Y),date(m),date(d));//获取当前节气

$url = "http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=".$INFOconfig['region']."&needMoreData=false&pageNo=1&pageSize=1";
$weather = json_decode(file_get_contents($url,true),true);

//随机一言
$yiyan0="http://api.mrfly.top/api/yiyan/yiyan.php?encode=json";
$yiyan = json_decode(file_get_contents($yiyan0,true),true);

if($weather["code"]!="0"){
    $return = array(
        "code"=> $weather['code'],
        "msg"=> "[".$weather["msg"]."]推送消息失败,请检查地区名是否有误!",
    );
    exit(Json($return));
}

$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$token;
$posts = array(
    "template_id"=>$WXconfig['template_id'],
    "url"=>"http://mrfly.top/",
    "topcolor"=>"#FF0000",
    "data"=>array(
        "date"=>array(
            "value"=> "今天是".date("Y年m月d日")." 农历".$today[1].$today[2]." ".$month[name2]."哦~",
            "color"=>random_color()
        ),
//完整内容请下载附件......

完整内容请下载附件......
https://mrfly.lanzouj.com/b00q1xp2d
密码:650y

本文共 339 个字数,平均阅读时长 ≈ 1分钟
58

打赏

海报

正在生成.....

评论 (0)

取消