where("userID",$userID)->find(); $account = Db::table("user_account")->where("accountID",$acco_适合公众号用的代码">
当前位置:   article > 正文

微信公众号代码推送_适合公众号用的代码

适合公众号用的代码

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);
}


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/70819
推荐阅读
相关标签
  

闽ICP备14008679号