So there I was trying to figure out how to get the app access token using the C# Facebook SDK. I read about how to get one from Facebook's documentation, but it said something about extracting the value from the query string. But that didn't make too much sense. So I played around with some code and got it to work.
var fb = new Facebook.FacebookClient(); dynamic tokenInfo = fb.Get( String.Format( "/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials", appId, appSecret)); var appAccessToken = (string)tokenInfo.access_token;
Yes, that simple. :)
Now with this app access token, I'm able to post on the each user's behalf if they granted me publish stream permissions. But what about if you want to post to a user's page? Well that is something that Facebook didn't make standard.
Here's what Facebook would like you to do.
1. Get a user access token
2. Extend that token to a 60-day token
3. Call /me/accounts and grab the access token from the page
This will be the non-expiring token you can use to publish with to the user's wall.
Happy coding!