|
導(dǎo)讀微信(WeChat)是騰訊公司于2011年1月21日推出的一個為智能終端提供即時通訊服務(wù)的免費應(yīng)用程序,由張小龍所帶領(lǐng)的騰訊廣州研發(fā)中心產(chǎn)品團隊打造 [2] 。微信支持跨通信運營商、跨操作系統(tǒng)平臺... 微信(WeChat)是騰訊公司于2011年1月21日推出的一個為智能終端提供即時通訊服務(wù)的免費應(yīng)用程序,由張小龍所帶領(lǐng)的騰訊廣州研發(fā)中心產(chǎn)品團隊打造 [2] 。微信支持跨通信運營商、跨操作系統(tǒng)平臺通過網(wǎng)絡(luò)快速發(fā)送免費(需消耗少量網(wǎng)絡(luò)流量)語音短信、視頻、圖片和文字,同時,也可以使用通過共享流媒體內(nèi)容的資料和基于位置的社交插件“搖一搖”、“漂流瓶”、“朋友圈”、”公眾平臺“、”語音記事本“等服務(wù)插件。 1、設(shè)置用戶備注名接口:https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN updateremark.php <?php
require_once("../Utils.php");
$data = '{
"openid":"o4WmZ0h-4huBUVQUczx2ezaxIL9c",
"remark":"Jhon"
}';
$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;返回: {"errcode":0,"errmsg":"ok"}2、獲取用戶基本信息接口: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;返回: {
"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、批量獲取用戶消息接口:https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN batchget.php <?php
require_once("../Utils.php");
$data = '{
"user_list": [
{
"openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",
"lang": "zh_CN"
}
]
}';
$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;返回: {
"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、創(chuàng)建標簽接口:https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN tags_create.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"tag" : {
"name" : "朋友"
}
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/create?"
."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;返回: {
"tag": {
"id": 101,
"name": "朋友"
}
}5、獲取以創(chuàng)建標簽接口:https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN tags_get.php <?php
@header('Content-type: text/plain;charset=UTF-8');
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;返回: {
"tags": [
{
"id": 2,
"name": "星標組",
"count": 0
},
{
"id": 100,
"name": "同學(xué)",
"count": 0
},
{
"id": 101,
"name": "朋友",
"count": 0
}
]
}6、編輯標簽接口:https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN tags_update.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"tag" : {
"id" : 101,
"name" : "好朋友"
}
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/update?"
."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;返回: {"errcode":0,"errmsg":"ok"}7、刪除標簽當(dāng)某個標簽下的粉絲超過10w時,后臺不可直接刪除標簽。此時,開發(fā)者可以對該標簽下的openid列表,先進行取消標簽的操作,直到粉絲數(shù)不超過10w后,才可直接刪除該標簽。 接口:https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN tags_delete.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"tag" : {
"id" : 101
}
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/delete?"
."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;返回: {"errcode":0,"errmsg":"ok"}8、批量為用戶打標簽標簽功能目前支持公眾號為用戶打上最多20個標簽。 接口:https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN tags_batchtagging.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"openid_list" : [
"o4WmZ0h-4huBUVQUczx2ezaxIL9c"
],
"tagid" : 100
}';
$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;返回結(jié)果: {"errcode":0,"errmsg":"ok"}9、獲取標簽下粉絲列表接口:https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN "next_openid":""//第一個拉取的OPENID,不填默認從頭開始拉取 tags_get_user.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"tagid" : 100,
"next_openid":""
}';
$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;返回: {
"count": 1,
"data": {
"openid": [
"o4WmZ0h-4huBUVQUczx2ezaxIL9c"
]
},
"next_openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
}10、獲取用戶身上的標簽列表接口;https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN tags_getidlist.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"openid" : "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?"
."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;返回: {
"tagid_list": [
100
]
}11、批量為用戶取消標簽 接口:https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN tags_batchuntagging.php <?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
"openid_list" : [
"o4WmZ0h-4huBUVQUczx2ezaxIL9c"
],
"tagid" : 100
}';
$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;返回: {"errcode":0,"errmsg":"ok"}以上就是微信公眾號實現(xiàn)用戶管理功能的詳細內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章! 微信提供公眾平臺、朋友圈、消息推送等功能,用戶可以通過“搖一搖”、“搜索號碼”、“附近的人”、掃二維碼方式添加好友和關(guān)注公眾平臺,同時微信將內(nèi)容分享給好友以及將用戶看到的精彩內(nèi)容分享到微信朋友圈。 |
溫馨提示:喜歡本站的話,請收藏一下本站!