Created
June 24, 2012 19:53
-
-
Save anuith/2984671 to your computer and use it in GitHub Desktop.
Windows Phone Hackathon : Facebook & Instagram Sample - Facebook Page Code - Get Access Token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public FacebookSample() | |
{ | |
InitializeComponent(); | |
// Get Access Token | |
GetAccessTokenAsync(); | |
} | |
private void GetAccessTokenAsync() | |
{ | |
string url = string.Format( | |
@"https://graph.facebook.com/oauth/access_token?" + | |
@"client_id={0}&client_secret={1}&grant_type=client_credentials", | |
appid, | |
appsecret | |
); | |
Uri accessTokenUri = new Uri(url); | |
WebClient webclient = new WebClient(); | |
webclient.DownloadStringCompleted += | |
new DownloadStringCompletedEventHandler(webclient_GetAccessTokenCompleted); | |
webclient.DownloadStringAsync(accessTokenUri); | |
} | |
private void webclient_GetAccessTokenCompleted | |
(object sender, DownloadStringCompletedEventArgs e) | |
{ | |
accessToken = e.Result.Replace("access_token=", ""); | |
Button_Go.IsEnabled = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment