1. 程式人生 > >微信公眾號開發教程[013]-使用者管理

微信公眾號開發教程[013]-使用者管理

        我承接app微信公眾號開發,如果有誰需要的話,可以惠顧我,謝謝.

QQ: 40678884

微信: szuzsq

-------------------------------------------------------------------------------------------------------------------------------------

        這個比較簡單,直接附上程式碼.

1).建立標籤

function create() { //建立標籤
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=$ACCESS_TOKEN";
	$data = '{"tag": {"name": "廣東"}}';
	$result = curl_http_post($url, $data);
	echo $result;
}

返回的結果如下:

{"tag":{"id":102,"name":"廣東"}}

2).獲取公眾號已建立的標籤

function query() { //獲取公眾號已建立的標籤
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token=$ACCESS_TOKEN";
	$result = curl_http_get($url);
	echo $result;
}
返回的結果如下:
{"tags":[{"id":2,"name":"星標組","count":0},{"id":102,"name":"廣東","count":0}]}

3).編輯標籤

function edit() { //編輯標籤
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token=$ACCESS_TOKEN";
	$data = '{"tag": {"id":100, "name": "廣西"}}';
	$result = curl_http_post($url, $data);
	echo $result;
}
返回的結果如下:
{"errcode":0,"errmsg":"ok"}

4).獲取標籤下粉絲列表

function get_list() { //獲取標籤下粉絲列表
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=$ACCESS_TOKEN";
	$data = '{"tagid" : 102,"next_openid":""}';
	$result = curl_http_post($url, $data);
	echo $result;
}

返回的結果如下:

{"count":0}



5).批量為使用者打標籤

function tagging() { //批量為使用者打標籤
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=$ACCESS_TOKEN";
	$data = '{"openid_list" : ["oe5SXv71irmrQ0TH-JxA-z_hmYLE","oe5SXv45Fq5lcB5jlxdBs6QWPNj8"],"tagid" : 102}';
	$result = curl_http_post($url, $data);
	echo $result;
}
返回的結果如下:
{"errcode":0,"errmsg":"ok"}



6).批量為使用者取消標籤
function untagging() { //批量為使用者取消標籤
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=$ACCESS_TOKEN";
	$data = '{"openid_list" : ["oe5SXv71irmrQ0TH-JxA-z_hmYLE","oe5SXv45Fq5lcB5jlxdBs6QWPNj8"],"tagid" : 102}';
	$result = curl_http_post($url, $data);
	echo $result;
}

返回的結果如下:

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



7).獲取使用者身上的標籤列表
function getidlist() { //獲取使用者身上的標籤列表
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=$ACCESS_TOKEN";
	$data = '{"openid" : "oe5SXv45Fq5lcB5jlxdBs6QWPNj8"}';
	$result = curl_http_post($url, $data);
	echo $result;
}

返回的結果如下:

{"tagid_list":[]}



8).設定使用者備註名
function updateremark() { //設定使用者備註名
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=$ACCESS_TOKEN";
	$data = '{"openid":"oe5SXv45Fq5lcB5jlxdBs6QWPNj8","remark":"愛人"}';
	$result = curl_http_post($url, $data);
	echo $result;
}

返回的結果如下:

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



9).獲取使用者基本資訊
function info() { //獲取使用者基本資訊
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$openid = "oe5SXv45Fq5lcB5jlxdBs6QWPNj8";
	$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$ACCESS_TOKEN&openid=$openid&lang=zh_CN";
	$result = curl_http_get($url);
	echo $result;
}
返回的結果如下:
{"subscribe":1,"openid":"oe5SXv45Fq5lcB5jlxdBs6QWPNj8","nickname":"nick","sex":2,"language":"zh_CN","city":"","province":"","country":"安道爾","headimgurl":"http://wx.qlogo.cn/mmopen/3JlWJcqsKP0E4oj7VtWyu0x0kfy4VMgUWVE1q85IrKN2DoHIJqiaZUssAFib6esFqvnzaq4EAqxoBqTeBPJf9apqoZPe0zpI6J/0","subscribe_time":1468307568,"remark":"愛人","groupid":0,"tagid_list":[]}



10).獲取關注的使用者列表
function user_list() { //獲取關注的使用者列表
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=$ACCESS_TOKEN&next_openid=";
	$result = curl_http_get($url);
	echo $result;
}

返回的結果如下:

{"total":3,"count":3,"data":{"openid":["oe5SXv45Fq5lcB5jlxdBs6QWPNj8","oe5SXv71irmrQ0TH-JxA-z_hmYLE","oe5SXv5IJ3vykrHVtYNBoshckf84"]},"next_openid":"oe5SXv5IJ3vykrHVtYNBoshckf84"}


11).刪除標籤

function delete() { //刪除標籤
	$ACCESS_TOKEN = "xtdVj6n_TwPDc-QtCSgXe8TQ0PrpTGpOg6Q4fxJcVHjPF9H2sHGJXXHqXr_q7dzgTP78dg3XV74tyB_-ThlUxSnV6HVP95E6NzX7x_-HHnSgqAYlP3Rju0vUzccWY79PDOLgACATEB";
	$url = "https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=$ACCESS_TOKEN";
	$data = '{"tag": {"id": 102}}';
	$result = curl_http_post($url, $data);
	echo $result;
}
返回的結果如下:
{"errcode":0,"errmsg":"ok"}