Skip to content

Instantly share code, notes, and snippets.

@anuith
Created June 24, 2012 19:53
Show Gist options
  • Save anuith/2984671 to your computer and use it in GitHub Desktop.
Save anuith/2984671 to your computer and use it in GitHub Desktop.
Windows Phone Hackathon : Facebook & Instagram Sample - Facebook Page Code - Get Access Token
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