public string Publish(string message) { var request = new FacebookRequest(String.Format(FacebookConst.UriMethodExecuteTemplate, User.FacebookUserId)); request.AccessToken = User.AccessToken; request.Parameters.Add("message", message); return request.Execute(FacebookMethod.Feed); }
public FacebookUser GetUser(string appCode) { var request = new FacebookRequest(FacebookConst.BaseUriGetUser); request.Parameters.Add("client_id", appId); request.Parameters.Add("client_secret", appSecret); request.Parameters.Add("redirect_uri", redirectCallbackUrl); request.Parameters.Add("code", appCode); string response = request.Execute(FacebookMethod.AccessToken); string[] fbParameters = response.Split('&'); var accessToken = fbParameters.Single(x => x.StartsWith(FacebookConst.ResponseAccessToken)).Split('=').Last(); var expires = fbParameters.Single(x => x.StartsWith(FacebookConst.ResponseExpireTime)).Split('=').Last(); return new FacebookUser() { AccessToken = accessToken, ExpireTime = DateTime.Now + TimeSpan.FromMilliseconds(Convert.ToInt32(expires)), FacebookUserId = "me", }; }