微信公众号代码推送

model

public function cashOutPush($accountID,$userID){
        $user = Db::table("user_info")->where("userID",$userID)->find();
        $account = Db::table("user_account")->where("accountID",$accountID)->find();
        $userInfo = Db::table("user_info")->where("isManager",1)->select();
        $title = "有新的提现申请";
        $content= "
提现申请:".$user["nick"]."
提现金额:".$account["amount"]."申请时间:".date("Y-m-d",$account["estTime"])."
";
        $url = Config::get("url")."index/Account/cashAccept";
        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.Config::get("APPID").'&redirect_uri='.$url.'&response_type=code&scope=snsapi_base&state=netvii#wechat_redirect';

        foreach($userInfo as $k=>$v){
            sendImgText($v["openID"],$title,$content,$url,"");
        }
    }
controller1
function sendImgText($openID,$title,$content,$url,$img){ //推送单图文客服消息
    $arr = array();
    $msg  = '{
           "touser":"'.$openID.'",
           "msgtype":"news",
           "news":{
                  "articles":[{
                         "title":"'.$title.'",
                         "description":"'.$content.'",
                         "url":"'.$url.'",
                         "picurl":"'.$img.'"
                   }]
            }

            }';
    array_push($arr,$msg);
    return sendMsg($arr);
}


function sendMsg($data){ //发送客服消息
    $token = getToken();
    for($i=0;$i<count($data);$i++){
        $json = stripslashes($data[$i]);
        $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}";
        $tmpInfo = myCurl($url,$json);
    }
    return $tmpInfo;
}

 
controller2
$pushModel = new PushModel();
$pushModel->cashOutPush($cashAccountID,Session::get("userInfo.userID"));






推送多图文:
public function firstPush($userID){
    $userInfo = db("user_info")->where("userID=".$userID)->find();
    $openID = $userInfo["openID"];
    $title1 = "欢迎关注永康基因";
    $title2 = "了解自己";
    $title3 = "申请代理";
    $content1 = "";
    $content2 = "";
    $content3 = "";
    $url1 = "";
    $url2 = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.Config::get("APPID").'&redirect_uri='.Config::get("url").'index/Dnagenenew/gene&response_type=code&scope=snsapi_base&state=netvii#wechat_redirect';
    $url3 = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.Config::get("APPID").'&redirect_uri='.Config::get("url").'index/Dnaagentnew/agent&response_type=code&scope=snsapi_base&state=netvii#wechat_redirect';

    $img1 = Config::get("image")."gene.jpg";
    $img2 = Config::get("image")."gene4.jpg";
    $img3 = Config::get("image")."agent.png";

    $arr = array();
    $msg  = '{
       "touser":"'.$openID.'",
       "msgtype":"news",
       "news":{
              "articles":[{
                     "title":"'.$title1.'",
                     "description":"'.$content1.'",
                     "url":"'.$url1.'",
                     "picurl":"'.$img1.'"
               },
               {
                     "title":"'.$title2.'",
                     "description":"'.$content2.'",
                     "url":"'.$url2.'",
                     "picurl":"'.$img2.'"
               },
               {
                     "title":"'.$title3.'",
                     "description":"'.$content3.'",
                     "url":"'.$url3.'",
                     "picurl":"'.$img3.'"
               }
               ]
        }

        }';
    array_push($arr,$msg);
    return sendMsg($arr);
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值