GetApplicationAccessToken() 공개 메소드

Gets the application access token.
public GetApplicationAccessToken ( ) : object
리턴 object
예제 #1
0
 /// <summary>
 /// Get Application Access Token
 /// </summary>
 /// <returns></returns>
 public string GetAppAccessToken()
 {
     var fb = new FacebookOAuthClient { AppId = "340791049284352", AppSecret = "c46526d851aaf7dd547a63ae332d3e49" };
     dynamic result = fb.GetApplicationAccessToken();
     var appAccessToken = result.access_token;
     return appAccessToken.ToString();
 }
예제 #2
0
        private static bool SendMessage(IEnumerable<long> pushIds, string subject, string templatePath, Dictionary<string, string> tokens)
        {
            FacebookOAuthClient oAuth = new FacebookOAuthClient(FacebookApplication.Current);
            dynamic tokenResponse = oAuth.GetApplicationAccessToken();
            string accessToken = tokenResponse.access_token;

            FacebookWebClient postApp = new FacebookWebClient(accessToken);

            string body = System.IO.File.ReadAllText(templatePath);

            tokens.Add("CanvasUrl", FacebookApplication.Current.ReturnUrlPath);

            foreach (string key in tokens.Keys)
            {
                body = body.Replace("{" + key + "}", tokens[key]);
            }

            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("method", "notifications.sendEmail");
            parameters.Add("recipients", string.Join(",", pushIds));
            parameters.Add("subject", subject);
            parameters.Add("fbml", body);
            dynamic messageResult = postApp.Post(parameters);

            return true;
        }