Home  >  Article  >  WeChat Applet  >  WeChat public account implements user management function

WeChat public account implements user management function

一个新手
一个新手Original
2017-09-14 10:47:505872browse

1. Set the user remark name

Interface: https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN

updateremark. php

<?php
require_once("../Utils.php");
$data = &#39;{
    "openid":"o4WmZ0h-4huBUVQUczx2ezaxIL9c",
    "remark":"Jhon"
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/user/info/updateremark?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{"errcode":0,"errmsg":"ok"}

2. Obtain basic user information

Interface: https://api.weixin.qq.com/cgi-bin/user/info ?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

userInfp.php

<?php
require_once("../Utils.php");
$openId = "o4WmZ0h-4huBUVQUczx2ezaxIL9c";
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token="
    .Utils::get_access_token()."&openid=".$openId."&lang=zh_CN ";
$result = Utils::https_request($url);
echo $result;

Return:

{
    "subscribe": 1,
    "openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",
    "nickname": "Promise",
    "sex": 1,
    "language": "zh_CN",
    "city": "",
    "province": "",
    "country": "",
    "headimgurl": "http://wx.qlogo.cn/mmopen/Vq7PMkMOaMYgtQNJBrdesiantXGgGkliaoI3StUtnG5DUA1oYaeTlOdjicYHu9EkMvLY2gXf7rHBzGNiaPoDyvmZ0ONEGm7PfGBb/0",
    "subscribe_time": 1504708412,
    "remark": "Jhon",
    "groupid": 0,
    "tagid_list": []
}

3. Get user messages in batches

Interface: https:/ /api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN

batchget.php

<?php
require_once("../Utils.php");
$data = &#39;{
    "user_list": [
       {
           "openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",
           "lang": "zh_CN"
       }
   ]
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{
    "user_info_list": [
        {
            "subscribe": 1,
            "openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",
            "nickname": "Promise",
            "sex": 1,
            "language": "zh_CN",
            "city": "",
            "province": "",
            "country": "",
            "headimgurl": "http://wx.qlogo.cn/mmopen/Vq7PMkMOaMYgtQNJBrdesiantXGgGkliaoI3StUtnG5DUA1oYaeTlOdjicYHu9EkMvLY2gXf7rHBzGNiaPoDyvmZ0ONEGm7PfGBb/0",
            "subscribe_time": 1504708412,
            "remark": "Jhon",
            "groupid": 0,
            "tagid_list": []
        }
    ]
}

4. Create Tag

Interface: https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN

tags_create.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
    "tag" : {
        "name" : "朋友"
  }
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/tags/create?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{
    "tag": {
        "id": 101,
        "name": "朋友"
    }
}

5. Get to create tags

Interface: https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN

tags_get.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token="
    .Utils::get_access_token();
$result = Utils::https_request($url);
echo $result;

Return:

{
    "tags": [
        {
            "id": 2,
            "name": "星标组",
            "count": 0
        },
        {
            "id": 100,
            "name": "同学",
            "count": 0
        },
        {
            "id": 101,
            "name": "朋友",
            "count": 0
        }
    ]
}

6. Edit tag

interface: https://api.weixin.qq.com/cgi-bin/tags/update ?access_token=ACCESS_TOKEN

tags_update.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
    "tag" : {
        "id" : 101,
    "name" : "好朋友"
  }
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/tags/update?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{"errcode":0,"errmsg":"ok"}

7. Delete tag

When the number of fans under a certain tag exceeds 100,000, Tags cannot be deleted directly in the background. At this time, developers can first cancel the label in the openid list under the label, and then delete the label directly until the number of fans does not exceed 100,000.

Interface: https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN

tags_delete.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
    "tag" : {
        "id" : 101
    }
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/tags/delete?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{"errcode":0,"errmsg":"ok"}

8. Tag users in batches

The tag function currently supports official accounts to tag up to 20 users.

Interface: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN

tags_batchtagging.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
    "openid_list" : [
        "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
    ],
  "tagid" : 100
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return result:

{"errcode":0,"errmsg":"ok"}

9. Get the list of fans under the tag

Interface: https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token =ACCESS_TOKEN

"next_openid":""//The first OPENID pulled, if not filled in, it will be pulled from the beginning by default

tags_get_user.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
  "tagid" : 100,
  "next_openid":""
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/user/tag/get?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{
    "count": 1,
    "data": {
        "openid": [
            "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
        ]
    },
    "next_openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
}

10. Get the tag list on the user

Interface; https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN

tags_getidlist.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
  "openid" : "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{
    "tagid_list": [
        100
    ]
}

11. Cancel tags for users in batches

Interface: https://api.weixin.qq.com/ cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN

tags_batchuntagging.php

<?php
@header(&#39;Content-type: text/plain;charset=UTF-8&#39;);
require_once("../Utils.php");
$data = &#39;{
    "openid_list" : [
        "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
    ],
  "tagid" : 100
}&#39;;
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

Return:

{"errcode":0,"errmsg":"ok"}

The above is the detailed content of WeChat public account implements user management function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn