天天看点

金蝶云php webapi,金蝶云星空(WebApi集成方式):免密码登录接口

免密码登录方式

首先在金蝶云星空进行第三方登录授权。

金蝶云php webapi,金蝶云星空(WebApi集成方式):免密码登录接口

第三方系统登录授权

登录接口定义:

/// 第三方系统登录授权

/// 数据中心ID

/// 用户名称

/// 第三方系统应用Id

/// 第三方系统应用秘钥

/// 语言id,中文为2052,中文繁体为3076,英文为1033

///

public string LoginByAppSecret(string dbId, string userName, string appId, string appSecret, int lcid)

返回结果:

{

"Message": null,

"MessageCode": null,

"LoginResultType": 1,// 0 密码错误,1 登录成功, -1 登录失败

"Context":{上下文信息相关}

"KDSVCSessionId": null,

"FormId": null,

"RedirectFormParam": null,

"FormInputObject": null,

"ErrorStackTrace": null,

"Lcid": 0,

"AccessToken": null,

"KdAccessResult": null,

"IsSuccessByAPI": true

}

代码示例

1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll)

引用组件Kingdee.BOS.WebApi.Client.dll

下载链接: https://pan.baidu.com/s/1RthbrrtUgeqWGi-eLM-yjg

提取码: eqin

private K3CloudApiClient apiClient = new K3CloudApiClient("http://localhost/k3cloud/");//serverUrl需要以“/”结尾

public bool LoginByAppSecret()

{

string appId = "203502_5f6p2avOzuDXX5XE617sywzt7Nw7Roru";

string appSecret = "2825766ee71f4002b24d78b6b9a9bc53";

string loginResult = apiClient.LoginByAppSecret(

"5dde42aa8b86d7",

"yz",

appId,

appSecret,

2052);

JObject loginResultObj = JObject.Parse(loginResult);

JToken loginResultType;

loginResultObj.TryGetValue("LoginResultType", out loginResultType);

// 登陆成功,开始保存数据

//loginResultType.Value():

// 0 密码错误

// 1 登录成功

// -1 登录失败

if (loginResultType != null && loginResultType.Value() == 1)

{

return true;

}

else

{

return false;

}

}

2)无引用组件示例(不引用金蝶的组件):

http://ServerIp/K3Cloud/接口命名空间.接口实现类名.方法,组件名.common.kdsvc

string appId = "203502_5f6p2avOzuDXX5XE617sywzt7Nw7Roru";

string appSecret = "2825766ee71f4002b24d78b6b9a9bc53";

HttpClient httpClient = new HttpClient();

httpClient.Url = "http://localhost/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.LoginByAppSecret.common.kdsvc";

List Parameters = new List();

Parameters.Add("5dde42aa8b86d7");//帐套Id

Parameters.Add("yz");//用户名

Parameters.Add(appId);

Parameters.Add(appSecret);

Parameters.Add(2052);

httpClient.Content = JsonConvert.SerializeObject(Parameters);

var iResult = JObject.Parse(httpClient.AsyncRequest())["LoginResultType"].Value();

if (iResult == 1)

{

//todo:验证成功,处理业务

}