by
7,382 32
0
7
2,617
1
Top 1% !
Popular
Famous
Tagged
Specified
Refined
OpenSource
Popularity: 6760th place
Created
Modified Sep 18, 2013

Published on:

.NETFramework4.0
Architecturex86_64
Extension.cs
InputName0username
InputName1password
InputType0string
InputType1string
LanguageCSharp
LicenseMIT_X11
MethodNameLogin
OSWindows
OutputTypeUser
Windows VersionWindows7

How to login with Snip2Code APIs

This is an example of the login procedure to consume Snip2Code APIs that need authorization. The simple HTTP request to the login endpoint is then deserialized and the resulting User object is returned as result.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/11205/How-to-login-with-Snip2Code-APIs?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public User Login(string username, string password) { string viewStateString = string.Empty; string postData = string.Format("{0}{1}={2}&{3}={4}&{5}={6}", viewStateString, "Username", HttpUtility.UrlEncode(username), "Password", HttpUtility.UrlEncode(password), "LoginBtn", "Login"); // now post to the login form string loginUrl = "http://www.snip2code.com/Access/Login" string response = SendRequest(loginUrl, postData, true); S2CResBaseEntity<User> resp = Deserialize(response); //you can use a third party library to pass from json-encoded response to the object... if ((resp != null) && (resp.Status == ErrorCodes.FAIL)) return null; if (resp == null) return null; else return resp.Data; }

Other Steps and Solutions

If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus