Browse Source

Merge branch 'master' of 192.168.1.5:BWPB3/B3WeChat

master
[zhengchao] 9 years ago
parent
commit
b79fec9900
3 changed files with 15 additions and 2 deletions
  1. +9
    -1
      B3WeChat/Entities/ErrorObject.cs
  2. +2
    -1
      B3WeChat/Entities/TokenObject.cs
  3. +4
    -0
      B3WeChat/Utils/InOutMessageUtil.cs

+ 9
- 1
B3WeChat/Entities/ErrorObject.cs View File

@ -7,7 +7,15 @@ namespace BWP.B3WeChat.Entities
{
public class ErrorObject
{
public string errcode { get; set; }
public int errcode { get; set; }
public string errmsg { get; set; }
public bool IsError
{
get
{
return errcode > 0;
}
}
}
}

+ 2
- 1
B3WeChat/Entities/TokenObject.cs View File

@ -8,9 +8,10 @@ namespace BWP.B3WeChat.Entities
/// <summary>
/// Token对象
/// </summary>
public class TokenObject
public class TokenObject:ErrorObject
{
public string access_token { get; set; }
public string expires_in { get; set; }
}
}

+ 4
- 0
B3WeChat/Utils/InOutMessageUtil.cs View File

@ -48,6 +48,10 @@ namespace BWP.B3WeChat.Utils
responseBody = Encoding.UTF8.GetString(bytes);
JavaScriptSerializer jsonHelper = new JavaScriptSerializer(); logger.Info("GetToken_responseBody:" + responseBody);
TokenObject obj = jsonHelper.Deserialize<TokenObject>(responseBody);
if (obj.IsError)
{
throw new Exception(string.Format("{0}:{1}", obj.errcode, obj.errmsg));
}
if (obj != null)
{
token = obj.access_token;


Loading…
Cancel
Save