本文整理汇总了C#中CommunicationHelper.ExecuteMethodReturnCookie方法的典型用法代码示例。如果您正苦于以下问题:C# CommunicationHelper.ExecuteMethodReturnCookie方法的具体用法?C# CommunicationHelper.ExecuteMethodReturnCookie怎么用?C# CommunicationHelper.ExecuteMethodReturnCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommunicationHelper
的用法示例。
在下文中一共展示了CommunicationHelper.ExecuteMethodReturnCookie方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginAsync
/// <summary>
/// Authenticates a user based on the specified user id and password hash.
/// </summary>
/// <param name="UserId">The id for a specific user</param>
/// <param name="PasswordHash">The password hash for the user</param>
/// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
/// <returns>Login (AccountStatus, AccountType, FileSizeLimit, SessionID, SmugVault, User (id, DisplayName, NickName, URL))</returns>
public async Task<MyUser> LoginAsync(int UserId, string PasswordHash, string Extras)
{
CommunicationHelper ch = new CommunicationHelper();
// APIKey [required], Callback, Extras, PasswordHash [required], Pretty, Sandboxed, Strict, UserID [required]
var tuple = await ch.ExecuteMethodReturnCookie<LoginResponse>("smugmug.login.withHash", null, "UserID", UserId, "PasswordHash", PasswordHash, "Extras", Extras);
var resp = tuple.Item1;
string su = tuple.Item2;
if (resp.stat == "ok")
{
MyUser u = new MyUser();
resp.Login.PopulateUser(u);
u.basic._su = su;
return u;
}
else
{
Console.WriteLine(resp.message);
throw new SmugMugException(resp.code, resp.message, resp.method);
}
}