php+创建微信标签,微信公众号——创建标签,给粉丝打标签。

1.创建标签

public function createTag($tag=''){

// 查库,是否有,没有创建,把tag和tag_id写到库中

$mp = $this->mp;

$tagname = "11";

$where['mp_id'] = $mp['id'];

$where['tag'] = $tagname;

$data = M('mp_tags')->where($where)->find();

if(empty($data)){

$api = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=" . getAccess_token();

$arr = array();

$arr['tag']['name'] = $tagname;

$json = json_encode($arr,JSON_UNESCAPED_UNICODE);

// dump($json);

// exit();

include APP_PATH . 'LaneWeChat/lanewechat.php';

$ret = \LaneWeChat\Core\Curl::callWebServer($api,$json,'POST');

// dump($ret);

// exit();

if ($ret['tag']) {

$row['mp_id'] = $mp['id'];

$row['tag_id'] = $ret['tag']['id'];

$row['tag'] = $ret['tag']['name'];

M('mp_tags')->add($row);

}

}

}

2.给粉丝打标签

public function openidTag(){

// $openid = "o7RZ_0Z-9OLCKEQ0PNEh5fr8neDc";

$openid = "o7RZ_0aaxcPh23BG2l-DUxHxN9J8";

$api = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=" . getAccess_token();

// $arr = array();

$arr['openid_list'] = array($openid);

$arr['tagid'] = 111;

$json = json_encode($arr);

// dump($json);

// exit;

include APP_PATH . 'LaneWeChat/lanewechat.php';

$ret = \LaneWeChat\Core\Curl::callWebServer($api,$json,'POST');

print_r($ret);

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值