收藏
回答

在小程序里面通过绑定的公众号发送模板消息?

在小程序里面通过绑定的公众号发送模板消息,问题如下:

1、是用https://api.weixin.qq.com/cgi-bin/message/template/send?access_token这个API发送吗?

2、access_tokens是用公众号的access_token吧?

3、其中data里面需要传递参数touser:接收消息的用户openid,这个openid是小程序的openid,还是服务号的openid呢?

	$weixin_config = array();
	$weixin_config['appid'] = load_model_class('front')->get_config_by_name('wepro_appid', $uniacid);
	$weixin_config['appscert'] = load_model_class('front')->get_config_by_name('wepro_appsecret', $uniacid);
	$jssdk = new Jssdk( $weixin_config['appid'], $weixin_config['appscert']);
	$re_access_token = $jssdk->getweAccessToken($uniacid);

      $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$re_access_token}";

  $data=
  {
    "touser": "OPENID",
    "template_id": "TEMPLATE_ID",
    "page": "index",
    "data": {
        "name01": {
            "value": "某某"
        },
        "amount01": {
            "value": "¥100"
        },
        "thing01": {
          "value": "广州至北京"
      },
      "date01": {
          "value": "2018-01-01"
      }
  };

	$result = $this->sendhttps_post($url, json_encode($data));





回答关注问题邀请回答
收藏

3 个回答

  • Hlxuan.
    Hlxuan.
    2天前

    1、是的;

    2、已完成微信认证服务号的 access_token;

    3、服务号下的 openid。

    2天前
    有用
    回复
  • sun
    sun
    2天前

    1.是的

    2.需要服务号的token。

    3.需要服务号下的openid

    2天前
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    2天前
    有用
登录 后发表内容