#region Apache License Version 2.0
/*----------------------------------------------------------------
Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
----------------------------------------------------------------*/
#endregion Apache License Version 2.0
/*----------------------------------------------------------------
Copyright (C) 2019 Senparc
文件名:WeixinUserInfoResult.cs
文件功能描述:获取用户信息返回结果
创建标识:Senparc - 20150211
修改标识:Senparc - 20150303
修改描述:整理接口
修改标识:Senparc - 20180305
修改描述: v14.10.4 WeixinUserInfoResult添加tagid_list属性(用户被打上的标签ID列表) 感谢@zhouxin9
修改标识:Senparc - 20181226
修改描述:v16.6.2 修改 DateTime 为 DateTimeOffset
----------------------------------------------------------------*/
using Senparc.CO2NET.Helpers;
using Senparc.Weixin.Entities;
using Senparc.Weixin.Helpers;
using System;
namespace Senparc.Weixin.MP.Entities
{
///
/// 用户信息
///
public class WeixinUserInfoResult : WxJsonResult
{
///
/// 用户是否订阅该公众号标识,值为0时,拉取不到其余信息
///
public int subscribe { get; set; }
///
/// 普通用户的标识,对当前公众号唯一
///
public string openid { get; set; }
///
/// 用户的昵称
///
public string nickname { get; set; }
///
/// 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
///
public int sex { get; set; }
///
/// 用户所在城市
///
public string city { get; set; }
///
/// 用户所在国家
///
public string country { get; set; }
///
/// 用户所在省份
///
public string province { get; set; }
///
/// 用户的语言,zh-CN 简体,zh-TW 繁体,en 英语,默认为zh-CN
///
public string language { get; set; }
///
/// 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。
/// 示例:http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0
///
public string headimgurl { get; set; }
///
/// 获取指定大小的用户头像网址
///
/// 代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像)
///
public string GetHeadImageUrl(int size = 0)
{
var url = headimgurl;
if (url == null)
return null;
var tail = "/" + size.ToString("d");
if (url.EndsWith(tail))
return url;
var slashIndex = url.LastIndexOf('/');
if (slashIndex < 0)
return url;
return url.Substring(0, slashIndex) + tail;
}
///
/// 用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间
///
public long subscribe_time { get; set; }
public DateTimeOffset GetSubscribeTime()
{
return DateTimeHelper.GetDateTimeFromXml(subscribe_time);
}
///
/// 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段
///
public string unionid { get; set; }
///
/// 公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注
///
public string remark { get; set; }
///
/// 用户所在的分组ID
///
public int groupid { get; set; }
///
/// 用户被打上的标签ID列表
///
public int[] tagid_list { get; set; }
}
}