Skip to main contentdfsdf

Home/ enaftiti's Library/ Notes/ Facebook Wpf App

Facebook Wpf App

from web site

=


Facebook Wpf App

Download

Facebook Wpf App

When the user logs out of a Windows app, you simply clear out any stored data. The UI includes a text box and a button to post. The name Mementoand its related iconwill show up as the footer of any wall posts made by any client app using Memento to connect to Facebook. Integrating Apps with Social Networks Most social networks have a similar architecture. The content you requested has been removed. To build a mobile app, you follow the same pattern discussed here. Dev centers Windows Office Visual Studio Microsoft Azure More.. By continuing to browse this site, you agree to this use. As you can imagine, the use of the Facebook API isnt limited to Web apps, even though one of its most common uses is just to authenticate users of a new Web site in a softer manner. The Facebook API, however, is the same. Dino Espositois the author of Architecting Mobile Solutions for the Enterprise (Microsoft Press, 2012) and Programming ASP.NET MVC 3 (Microsoft Press, 2011), and coauthor of Microsoft .NET: Architecting Applications for the Enterprise (Microsoft Press, 2008). The endpoint, however, returns an HTML page for the actual user to interact with by entering credentials and authorizing the connector to operate on her behalf (see Figure 2). Note that once the user has logged in successfully, the app is still not yet ready to operate on behalf of the user. Page Info Change History (all pages) All Project Updates Discussions Issue Tracker Downloads Reviews Source Code Wiki & Documentation Subscribe . Finally, the Navigate method directs the component to the specified URL. Project Description This is a WPF sample application for Facebook OAuth authentication in C#. The same user has a different access token for different connectors. The access code tells the social network engine whether the user app has enough permission to perform the requested operation on behalf of that user. Figure 1 The Interaction Model of Social Networks In the end, any user apps that need to integrate with most popular social networks (for example, Facebook, Twitter or Foursquare) are essentially built as clients of a social network-specific connector app. Figure 6 shows the C# code to get the access token after a successful OAuth login. Note that the pattern is valid regardless of the mobile platform of choice. Figure 1 summarizes the overall architecture of social networks when it comes to interaction. At the minimum, you need to have a couple of buttons to trigger the login and logout process, and a label to display the name of the currently logged-in user. You can create a connector for Facebook at developers.facebook.com/apps. If the user is not logged in, the page shown in Figure 4 is presented. Figure 2 The Memento Connector Explicitly Asks the User for Permissions The part thats different in a Windows or mobile scenario compared to a Web app is how you handle the redirect to the HTML page that the social network provides for credentials and permissions. What else? Lets look at the code you put in the Login click handler: XML Copy var loginUrl = FbHelpers.GetLoginUrl(); The first step is getting the login URL from Facebook. A social network is primarily a Web app and exposes authentication services via the OAuth protocol. A client app (Web site, WPF or Windows Phone) can only interact with the engine of the social network through the mediation of a connector. Once you hold the access token for a given user and connector, youre ready to perform any operation that falls under the granted permissions, as shown in Figure 2.A common type of social network app listens to some feed and posts automatically on behalf of the same user. For the sample code accompanying this column, Ill use a Facebook connector called Memento (note that the code, provided for example purposes, comes as a single project, not a full solution, and uses Visual Studio 2010). Figure 6 Code to Get Access Token After Successful OAuth Login XML Copy public static String GetAccessToken(FacebookOAuthResult oauthResult) { var client = new FacebookClient(); dynamic result = client.Get("/oauth/accesstoken", new { clientid = ConfigurationManager.AppSettings["fbkey"], clientsecret = ConfigurationManager.AppSettings["fbsecret"], redirecturi = " code = oauthResult.Code }); return result.accesstoken; } In a Web app, you might want to persist the access token in a custom cookie or as extra data in a custom authentication cookie managed by a custom IPrincipal object. January 2013 Volume 28 Number 01 Cutting Edge - Essential Facebook Programming: Building a Windows Client By Dino Esposito January 2013 Get the Code: VB In my previous column I discussed the basics of Facebook programming in the context of a Web sitespecifically an ASP.NET MVC Web site (you can read the article at msdn.microsoft.com/magazine/jj863128). Thats the landing page for after the login process has terminated. Once you hold the access token, you dont need to deal with authentication as long as the user behind the token is actually logged in to the social network on the computer.Posting Status and PhotosFigure 7 shows the UI of the sample WPF app once the user is successfully logged in to Facebook and the access token is safely stored. The code to get the URL is the same as youd use in a Web scenario, as shown in Figure 3.Figure 3 Code to Get Login URL XML Copy public static String GetLoginUrl() { var client = new FacebookClient(); var fbLoginUri = client.GetLoginUrl(new { clientid = ConfigurationManager.AppSettings["fbkey"], redirecturi = " responsetype = "code", display = "popup", scope = "email,publishstream" }); return fbLoginUri.ToString(); } As you might notice, the redirecturi parameter (required) points to a Facebook success endpoint. Yet Another Facebook Windows Client Lets create a WPF project and add a bit of XAML markup to the main window. In a Windows scenario, you might want to resort to local storage. As you can see, the UI also defines a button to browse and selects a JPEG image from the local disk.Figure 7 Posting from the Sample Client AppThe code in Figure 8 shows how to post an update with an attached picture.Figure 8 Code to Post an Update with an Attached Picture XML Copy public static void PostWithPhoto( String token, String status, String photoPath) { var client = new FacebookClient(token); using (var stream = File.OpenRead(photoPath)) { client.Post("me/photos", new { message = status, file = new FacebookMediaStream { ContentType = "image/jpg", FileName = Path.GetFileName(photoPath) }.SetValue(stream) }); } } In Figure 7 you see the update and picture posted to my timeline 5a02188284

hack de uberstrike facebook 2014
facebook hack programm erfahrung
2014 fotos para facebook
facebook app multiple subdomains
suvichar in marathi for facebook
facebook like box html code
deactivated facebook account still searchable
bb 8310 facebook chat
facebook desktop version for nokia e71
facebook pdi download baixar

enaftiti

Saved by enaftiti

on Jan 10, 18