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