ArticleDirectory
- What is Windows Live SDK?
- Hands-on practice-cloud album of SkyDrive
Windows Phone cloud application development practices (2)
Windows Live SDK what is Windows Live SDK?
The Windows Live id sdk contains Windows Live APIs, allowing your applications to connect to the Internet through MSN, allowing you to easily experience Microsoft cloud services such as Hotmail, SkyDrive, and Windows Live Messenger.
The value of "MSN connection" based on Windows Live SDK can solve login difficulties and improve user activity for developers. Using the SkyDrive interface, you can create cloud services at no cost. It can also be your application.ProgramOccupies the calendar portal; imports user friends to spread the mood. Microsoft uses Windows Live ID to create a cloud experience platform, ensuring that users can enjoy the same user experience across platforms, enrich Metro application functions, and make metro and our lives closer.
Figure MSN connection
Supported platforms for MSN connection: Metro application (window 8), web, and Windows Phone. So what can we do with Windows Live SDK-based "MSN connection" on Windows Phone platform?
- Use MSN to log on
By calling the signinbutton of the SDK, a third-party Windows Phone client can easily implement the MSN account logon function.
Figure MSN Login
After a user logs on, the app can easily obtain the user's basic information, including the name, profile picture, user MSN friend information, email, birthday, work, gender, address and phone number. The application can also publish user dynamic information, which will be displayed on Windows Phone contacts (People hub) and MSN signatures.
Figure publish user dynamic information to contacts
- Call Hotmail Interface
By calling the Hotmail interface, the Windows Phone application can access your calendar, read, write, update, and delete calendar events, and subscribe to common calendar events.
Figure weather show the weather information on the mobile phone screen saver calendar
- Call the SkyDrive Interface
By calling the SkyDrive interface, the Windows Phone application can read files stored on SkyDrive, and the user can directly process the files in the application (such as giving a photo a later effect ); by calling the SkyDrive interface, Windows Phone applications can also store data and files on users' SkyDrive to achieve cross-system and cross-platform data sharing. by calling the SkyDrive interface, the Windows Phone application can share files with your friends or process files collaboratively. As we all know, SkyDrive is very convenient for file sharing and collaboration.
Hands-on practice-cloud album of SkyDrive
This section uses the Windows Live SDK to call the SkyDrive interface. Log on to Windows Live In the webbrowser control and call the SkyDrive API to access images stored on the cloud after the application is authorized.
- Preparations
Configure the development environment
Install live software development kit (SDK );
Register an application
Before development, goHttps://manage.dev.live.comRegister your application. On this website, log in with a Windows Live account. After logon, click "create application" To Go To The application creation page and enter the program name and default language, click "I accept" to create a client ID and client secret to identify the application and use live connect to obtain user data.
Note:
If your redirect domain is the primary domain name, you can still use the subdomain name in the program for redirect domain. (For example, you can useHttp://luckyboy.comRegistered as redirect domain, but your callback page in the program can beIam.luckyboy.com)
- Oauth2.0 Basic Principles
The basic principle of oauth2.0 is to allow users to provide a token, rather than the user name and password, to access the data they store in a specific service provider. Each token authorizes a specific website (for example, a video editing website) at a specific time period (for example, within the next two hours) to access specific resources (for example, only videos in a photo album ). In this way, oauth2.0 allows users to authorize third-party websites to access the information they store on another service provider without sharing their access permission or all the content of their data. For more information, visit the official website http://www.oauth.net/2 /.
The live Connect service provides two calling methods: javascript API and rest API, which can be used at the front-end or backend.
User prompt Interface Description
When a user logs on using the live Connect service for the first time, the live Connect service displays a dialog box Indicating whether to allow access. This dialog box shows you the information about the users that your website needs to access, to personalize this dialog box, refer to the following information:
Display content |
Attribute |
1. website logo |
On the Basic Information page , application logo image set attributes |
2. website domain name |
On the API Settings page , redirect domain set attributes |
3. website name |
On the Basic Information page , application name set attributes |
4. hyperlink to website Terms of Use |
On the Basic Information page , terms of Service URL set attributes |
5.Website Privacy Statement hyperlink |
InBasic InformationPage, Privacy URLSet Properties |
The following is a detailed description of the image:
Detailed description
Implement oauth2.0 VerificationCodeAs follows:
Project: SkyDrive photos sample file: mainpage. XAML. CS
Remove
/// <Summary>
/// The URI for the oauth Service's authorize endpoint.
/// </Summary>
Private Static Readonly StringOauthauthorizeuri =Https://oauth.live.com/authorize";
/// <Summary>
/// Build the oauth Uri.
/// </Summary>
/// <Param name = "Scopes"> the requested scopes. </param>
/// <Returns> the oauth URI. </returns>
PrivateUri buildoauthuri (String[] Scopes)
{
List <String> Paramlist =NewList <String> ();
Paramlist. Add ("Client_id ="+ Httputility. urlencode (mainpage. clientid ));
Paramlist. Add ("Scope ="+ Httputility. urlencode (string. Join ("", Scopes )));
Paramlist. Add ("Response_type ="+ Httputility. urlencode ("Token"));
Paramlist. Add ("Display ="+ Httputility. urlencode ("Touch"));
Paramlist. Add ("Redirect_uri ="+ Httputility. urlencode (mainpage. redirecturi ));
Uribuilder authorizeuri =NewUribuilder (mainpage. oauthauthorizeuri );
Authorizeuri. query = string. Join ("&", Paramlist. toarray ());
ReturnAuthorizeuri. Uri;
}
/// <Summary>
/// Launch the oauth flow.
/// </Summary>
Private VoidLaunchoauthflow ()
{
This. Loadinggrid. Visibility = visibility. visible;
This. Authorizationbrowser. Navigating + =This. Onauthorizationbrowsernavigating;
This. Authorizationbrowser. navigated + =This. Onauthorizationbrowsernavigated;
This. Authorizationbrowser. navigate (This. Buildoauthuri (This. Scopes ));
}
Source codeFile
- userinfo. CS -- represents JSON User information data returned by the request
- albuminfo. CS -- represents JSON User album data returned by the request
- mainpage. XAML. CS -- main logic processing of applications