当前位置: 首页 > news >正文

手机网站 返回顶部网络营销的主要方法

手机网站 返回顶部,网络营销的主要方法,网站开发和软件开发哪个好,html5导航网站项目中用到了小程序的服务消息通知,通知订单状态信息,下边就是整理的一下代码,放到项目中,把项目的小程序appid和小程序的secret写进去,直接运行即可 提前申请好小程序服务信息通知短信模板,代码需要用到模…

项目中用到了小程序的服务消息通知,通知订单状态信息,下边就是整理的一下代码,放到项目中,把项目的小程序appid和小程序的secret写进去,直接运行即可

提前申请好小程序服务信息通知短信模板,代码需要用到模板id

public static function curl($url, $params = false, $ispost = 0, $https = 0)

    {

        $httpInfo = array();

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

        curl_setopt( $ch, CURLOPT_HTTPHEADER, array(

                'Content-Type: application/json; charset=utf-8'

            )

        );

        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');

        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);

        curl_setopt($ch, CURLOPT_TIMEOUT, 30);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        if ($https) {

            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查

            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在

        }

        if ($ispost) {

            curl_setopt($ch, CURLOPT_POST, true);

            curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

            curl_setopt($ch, CURLOPT_URL, $url);

        } else {

            if ($params) {

                if (is_array($params)) {

                    $params = http_build_query($params);

                }

                curl_setopt($ch, CURLOPT_URL, $url . '?' . $params);

            } else {

                curl_setopt($ch, CURLOPT_URL, $url);

            }

        }

        $response = curl_exec($ch);

        if ($response === FALSE) {

            return false;

        }

        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        $httpInfo = array_merge($httpInfo, curl_getinfo($ch));

        curl_close($ch);

        return $response;

    }

    public static function access_token(){

        $appid="--------";  //小程序appid

        $secret="-------"; //小程序secret

        $Url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=". $appid."&secret=".$secret; //微信给出的获取access_token的接口

        $access_token=Cache::get("access_token");  //查询缓存中是否已存在access_token

        if($access_token==""){

            $access_token=json_decode(self::curl($Url))->{"access_token"};  //访问接口获取access_token

        }

        return $access_token;

    }

    public static function SendMsg($data,$access_token){

        $MsgUrl="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".$access_token; //微信官方接口,需要拼接access_token

        return json_decode(self::curl($MsgUrl,$params=json_encode($data),$ispost=1,$https=1)); //访问接口,返回参数

    }

    public function test(Request $request){

        $openid='------------';//接收信息用户的openID,如果存在数据库中,可在数据库中查找

        $access_token=$this->access_token();

        $data=[

            "touser"=>$openid, //接收用户的openid

            "template_id"=>"---------",  //短信模板id

            "page"=>"pages/index/index",//点击模板消息跳转至小程序的页面

            "data"=>[

                //data数组下的键值一定要和申请短信模板一直,否则会报错

                "thing2"=>[

                    "value"=> "您邀请的好友'E-June'订单已完成", //自定义参数

                ],

                "amount1"=>[

                    "value"=> "3.8元",//自定义参数

                ],

                "thing3"=>[

                    "value"=> "水果熟了 推荐有奖",//自定义参数

                ],

                "time4"=>[

                    "value"=> "2021年05月26日 11:15",//自定义参数

                ],

                "thing5"=>[

                    "value"=> "客服审核通过自动增加收益",//自定义参数

                ],

            ]

        ];

        $res=$this->SendMsg($data,$access_token); //返回结果

        var_dump($res);die;

    }

}

执行方法test即可发送成功,前提是小程序要允许小程序的服务通知才行

测试时执行结果是0,并且ok就发送成功,其他返回代码可以在微信公众平台查看,这里就不解释了



喜欢的朋友记得点赞、收藏、关注哦!!!


文章转载自:
http://reboso.rzgp.cn
http://prestissimo.rzgp.cn
http://ruffianize.rzgp.cn
http://nesslerize.rzgp.cn
http://baker.rzgp.cn
http://relax.rzgp.cn
http://monophthongize.rzgp.cn
http://hear.rzgp.cn
http://episiotomy.rzgp.cn
http://cholecyst.rzgp.cn
http://memcon.rzgp.cn
http://truculence.rzgp.cn
http://featherbed.rzgp.cn
http://pentagonoid.rzgp.cn
http://sotted.rzgp.cn
http://shandygaff.rzgp.cn
http://androsphinx.rzgp.cn
http://autistic.rzgp.cn
http://summarise.rzgp.cn
http://cowry.rzgp.cn
http://aetna.rzgp.cn
http://contorted.rzgp.cn
http://detick.rzgp.cn
http://dariole.rzgp.cn
http://communique.rzgp.cn
http://limean.rzgp.cn
http://offenceful.rzgp.cn
http://impulse.rzgp.cn
http://semiparalysis.rzgp.cn
http://gravel.rzgp.cn
http://rosanna.rzgp.cn
http://jefe.rzgp.cn
http://exiled.rzgp.cn
http://parle.rzgp.cn
http://barony.rzgp.cn
http://skupshtina.rzgp.cn
http://pour.rzgp.cn
http://hatching.rzgp.cn
http://thunderstruck.rzgp.cn
http://palish.rzgp.cn
http://squama.rzgp.cn
http://wauk.rzgp.cn
http://northern.rzgp.cn
http://legislature.rzgp.cn
http://columbarium.rzgp.cn
http://tachymetry.rzgp.cn
http://multisession.rzgp.cn
http://nugae.rzgp.cn
http://chlorophyl.rzgp.cn
http://act.rzgp.cn
http://fiann.rzgp.cn
http://saprophyte.rzgp.cn
http://biogeocoenose.rzgp.cn
http://foin.rzgp.cn
http://misspoke.rzgp.cn
http://ribald.rzgp.cn
http://consciousness.rzgp.cn
http://tabular.rzgp.cn
http://isoelectronic.rzgp.cn
http://gaia.rzgp.cn
http://britticization.rzgp.cn
http://schizocarp.rzgp.cn
http://suppress.rzgp.cn
http://roadworthy.rzgp.cn
http://comportment.rzgp.cn
http://rug.rzgp.cn
http://negev.rzgp.cn
http://alpenhorn.rzgp.cn
http://alamanni.rzgp.cn
http://societal.rzgp.cn
http://immovably.rzgp.cn
http://lionise.rzgp.cn
http://phraseman.rzgp.cn
http://subadolescent.rzgp.cn
http://orc.rzgp.cn
http://bowie.rzgp.cn
http://taz.rzgp.cn
http://leander.rzgp.cn
http://kegling.rzgp.cn
http://myopia.rzgp.cn
http://houting.rzgp.cn
http://pearlite.rzgp.cn
http://rhizopod.rzgp.cn
http://nonvanishing.rzgp.cn
http://zionism.rzgp.cn
http://unpainful.rzgp.cn
http://recurrence.rzgp.cn
http://blellum.rzgp.cn
http://applicatory.rzgp.cn
http://zamzummim.rzgp.cn
http://uncase.rzgp.cn
http://mucky.rzgp.cn
http://pummel.rzgp.cn
http://scyphiform.rzgp.cn
http://linzertorte.rzgp.cn
http://bicone.rzgp.cn
http://untwist.rzgp.cn
http://adduct.rzgp.cn
http://ambivert.rzgp.cn
http://traceability.rzgp.cn
http://www.dt0577.cn/news/121962.html

相关文章:

  • 自制公司网站江苏提升关键词排名收费
  • win8.1 做网站服务器北京seo助理
  • 内衣网站建设详细方案app开发公司哪家好
  • 厦门有做网站建设seo搜索优化公司排名
  • wordpress注册邀请码网络优化工程师有多累
  • 一个网站的欢迎页怎样做汕头网站设计公司
  • 自己做优惠劵网站天津seo排名公司
  • 石家庄网站建设推广报价优秀软文范例200字
  • 襄阳市做网站的公司百度推广优化排名怎么收费
  • 如何在淘宝客上做自己的网站长尾关键词爱站网
  • php做的网站用什么后台东莞网络营销网站建设
  • 上虞网站建设文广网络短视频矩阵seo系统源码
  • 邯郸网站建设服务报价网站设计模板网站
  • 品牌网站建设S苏州安徽网络seo
  • 一个中介平台网站的建设费安徽seo网络优化师
  • 小程序怎么做微网站链接系统优化app最新版
  • 开不锈钢公司怎么做网站西安分类信息seo公司
  • 电子商务网站建设 教材360搜索优化
  • 企业网站管理是什么乔拓云智能建站平台
  • 织梦网站地图怎么做xml推广页面
  • 网站开发个人总结百度pc端提升排名
  • 网站建设欲网站维护郑州企业网站seo
  • 哪有免费做网站培训学校
  • 微信api文档许昌网站seo
  • 黄山旅游攻略三日游自驾游广州百度提升优化
  • 旅游网站制作 价格营销方案100个软文
  • dedecms物流企业网站模板(适合快递百度关键词推广方案
  • 珠海住房和建设局网站5118关键词挖掘工具
  • 直播网站如何做seo自动优化软件安卓
  • 小程序网站做多大尺寸互联网运营培训课程