Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
Windows Phone Zone is brought to you in partnership with:

Rabeb is a fresh graduate computer engineer. She specializes in User Experience Technologies including Windows Phone 7 and Windows 8, in addition to C# and .NET Technologies. She was selected for the Microsoft reality show Career Factor as Windows Phone 7 Finalist .She is passionate about new technologies . She is an avid proponent of social media , enjoy blogging http://rabeb.wordpress.com and tweeting @Rabeb_Othmani Rabeb is a DZone MVB and is not an employee of DZone and has posted 4 posts at DZone. You can read more from them at their website. View Full User Profile

Using SkyDrive in Your Windows Phone App: Part 1

02.03.2012
Email
Views: 1496
  • submit to reddit
It's so easy to get up and running with your first Windows Phone app!  Just pick up the FREE toolkit from Microsoft, register at AppHub, and start checking out some fundamental tutorials.

In case you don’t know what is Skydrive, on Wikipedia you will find that “ Windows Live SkyDrive, initially called Windows Live Folders, is a free-of-charge file hosting service that allows users to upload files to a cloud storage and then access them from a Web browser.”

That was true before the BUILD. Now, Microsoft released an SDK that enables us to write  third party applications running on Windows 7, Windows Developer Preview and Windows Phone, that interact with the whole Live services, SkyDrive among them in different languages : JavaScript, C# and REST.

It also released its official Skydrive application for both Windows Phone and iOS.







Get Ready

First of all you have to download ans install the Live SDK v5.0 . You would probably need to use the Live Interactive SDK to explore the APIs and learn how to use them.

The Live Connect should recognize your application, that’s why you should go to Live Connect App Management site and create a new app.

create


You will get a Client ID and Client Secret that you will be using later with your application.

clientbis

 

Demo : Sign In

Let’s see how it works now:

Create a Windows Phone Application and make sure to add the following references:

references


You should also add the SignIn Button to your toolbox :

toolbox


In the main page, the user should sign in :

Main



 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
              <TextBlock Height="55" HorizontalAlignment="Left" Margin="54,113,0,0"
                         Name="textBlock1" Text="Please sign in to access your Skydrive"
                         VerticalAlignment="Top" Width="336" />
              <my:SignInButton Content="Button" ClientId="Your_Client_ID"
                               Scopes="wl.signin wl.basic " Branding="Windows" SessionChanged="signInButton1_SessionChanged"
                               Height="72" HorizontalAlignment="Left" Margin="138,268,0,0"
                               Name="signInButton1" VerticalAlignment="Top" Width="160" />
              <TextBlock Height="32" HorizontalAlignment="Left" Margin="12,372,0,0" Name="infoTextBlock" Text=""
                         VerticalAlignment="Top" Width="419" />
 
          </Grid>


In the MainPage.xaml, I added a SingInButton control, You should put your own Client ID. I only used wl.signin and wl.basic scopes at this point.

wl.basic : Allows access to a user’s basic info, such as his or her Hotmail contact list.

wl.signin : Allows user’s log in .

The “infoTextBlock “ will indicate either the user is signed in or not. That will be handled in the C# code.

private void signInButton1_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
          {
              if (e.Status == LiveConnectSessionStatus.Connected)
              {
                  session = e.Session;
                  client = new LiveConnectClient(session);
                  infoTextBlock.Text = "Signed in.";
              }
              else
              {
                  infoTextBlock.Text = "Not signed in.";
                  client = null;
              }
 
          }


Run the application , hit the sign in button and you should get this screen:

sign in


Summary

In this first part, we grabbed the tools and SDK needed in order to use Skydrive in our Windows Phone applications.

Then we learnt how to sign in into Skydrive storage without writing any code.

In part two, we will learn how to read/insert files into Skydrive. Stay Tuned Sourire



Source: http://rabeb.wordpress.com/2012/01/07/using-skydrive-in-your-windows-phone-applications-part-1/

Published at DZone with permission of Rabeb Othmani, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

The Windows Phone Microzone, which is supported by Microsoft, is your one-stop-shop for news, tutorials, perspectives, and research on the mobile platform that is making waves in smartphone ecosystem.