# 接口客户端: 点我下载
# 接口客户端使用示例(c#):
namespace Mc.OpenPlatform.Tests
{
/// <summary>
/// [获取Token和用户信息接口]入参
/// </summary>
public class GetUserTokenParam
{
/// <summary>
/// Ticket
/// </summary>
public string Ticket { get; set; }
}
public class UnitTest1
{
public void TestMethod1()
{
//初始化接口客户端
Mc.OpenPlatform.Util.APIClient.Init("应用ID", "公钥", "私钥", "https://openapi10.mallcoo.cn/");
//参数赋值
var param = new GetUserTokenParam();
param.Ticket = "6321fa1234565b9e" ;
//调用接口
var resultStr = Mc.OpenPlatform.Util.APIClient.GetInstance.Post("User/OAuth/v1/GetToken/ByTicket/", Newtonsoft.Json.JsonConvert.SerializeObject(param));
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# MD5加密方法示例代码(c#):
/// <summary>
/// MD5加密(16位)
/// </summary>
/// <param name="EncryptString">需要加密的字符串</param>
/// <returns></returns>
public static string MD5EncryptTo16(string EncryptString)
{
if (string.IsNullOrEmpty(EncryptString)) { throw (new Exception("密文不得为空")); }
string tt = FormsAuthentication.HashPasswordForStoringInConfigFile(EncryptString, "MD5");
if (tt == "" || tt.Length < 30)
{
return string.Empty;
}
else
{
//Substring(startIndex,length):从此实例检索子字符串,子字符串从指定的字符位置开始且具有指定的长度。
//startIndex:此实例中子字符串的起始字符位置(从零开始)
//length:子字符串中的字符数
return tt.Substring(8, 16);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23