用戶標簽
獲取所有標簽
$officialAccount->userTag->list();
使用示例:
$tags = $officialAccount->userTag->list();
獲取結果:
{
"tags": [
{
"id": 0,
"name": "標簽1",
"count": 72596
},
{
"id": 1,
"name": "標簽2",
"count": 36
},
// ...
]
}
創建標簽
$officialAccount->userTag->create($name);
使用示例:
$officialAccount->userTag->create('測試標簽');
修改標簽信息
$officialAccount->userTag->update($tagId, $name);
使用示例:
$officialAccount->userTag->update(12, "新的名稱");
刪除標簽
$officialAccount->userTag->delete($tagId);
獲取指定 openid 用戶所屬的標簽
$userTags = $officialAccount->userTag->userTags($openId);
獲取結果:
{
"tagid_list":["標簽1","標簽2"]
}
獲取標簽下用戶列表
<?php
// $nextOpenId:第一個拉取的 OPENID,不填默認從頭開始拉取
$officialAccount->userTag->usersOfTag($tagId, $nextOpenId = '');
獲取結果示例:
{
"count":2, // 這次獲取的粉絲數量
"data":{ // 粉絲列表
"openid":[
"ocYxcuAEy30bX0NXmGn4ypqx3tI0",
"ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"
]
},
"next_openid":"ocYxcuBt0mRugKZ7tGAHPnUaOW7Y" // 拉取列表最后一個用戶的openid
}
批量為用戶添加標簽
<?php
$openIds = [$openId1, $openId2, ...];
$officialAccount->userTag->tagUsers($openIds, $tagId);
批量為用戶移除標簽
<?php
$openIds = [$openId1, $openId2, ...];
$officialAccount->userTag->untagUsers($openIds, $tagId);