опубликовать на странице приложения Facebook как приложение, используя Facebook c # SDK - PullRequest
2 голосов
/ 26 июля 2011

Мне нужно опубликовать пост на странице своего профиля приложения, а не пользователя, вот код:

 var fb = new FacebookOAuthClient(FacebookApplication.Current);
            dynamic resultt = fb.GetApplicationAccessToken();
            var appAccessToken = resultt.access_token;
            dynamic messagePost = new ExpandoObject();
            messagePost.access_token = appAccessToken;
            messagePost.picture = "";
            messagePost.link = "";
            messagePost.name = "[SOME_NAME]";
            messagePost.caption = "{*actor*} " + "[YOUR_MESSAGE]"; //<---{*actor*} is the user (i.e.: Aaron)
            messagePost.description = "[SOME_DESCRIPTION]";

            FacebookClient appp = new FacebookClient(appAccessToken);

            try
            {
                var result = appp.Post("/" + appId + "/feed", messagePost);
            }
            catch (FacebookOAuthException ex)
            {
                 //handle something
            }
            catch (FacebookApiException ex)
            {
                 //handle something else
            }

or
  var fb = new FacebookClient(appId, FacebookApplication.Current.AppSecret);
            var appAccessToken = fb.AccessToken;

1 Ответ

1 голос
/ 26 июля 2011

вот код:

var fb = new FacebookOAuthClient(FacebookApplication.Current);
            dynamic resultt = fb.GetApplicationAccessToken();
            var appAccessToken = resultt.access_token;

            dynamic messagePost = new ExpandoObject();
            messagePost.access_token = appAccessToken;
            messagePost.picture = "http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg";
            messagePost.link = "http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg";
            messagePost.name = "[SOME_NAME]";
            messagePost.caption = "{*actor*} " + "[YOUR_MESSAGE]";
            messagePost.description = "[SOME_DESCRIPTION]";
            messagePost.from = AppId;
            messagePost.to = "130736200342432";
            FacebookClient appp = new FacebookClient(appAccessToken);
            var result = appp.Post("/" + AppId + "/feed", messagePost);
...