开发者

Facebook C# SDK - Mobile Web Page : Facebook Wall Post URL Redirect

开发者 https://www.devze.com 2023-03-16 19:24 出处:网络
I am currently working on a mobile web page in asp.Net MVC2 that allows users to post to their walls. I have the following code that posts to the user\'s wall, but would like to instead have a redirec

I am currently working on a mobile web page in asp.Net MVC2 that allows users to post to their walls. I have the following code that posts to the user's wall, but would like to instead have a redirect to Facebook's mobile "Post To my Wall" view to allow the user to add to the posted message and submit with a "Post" button or "Cancel". Do I have to recreate this view myself? It seems like something that a lot of sites would use.

 public string PostToWall(string code)
        {
            string authToken = string.Empty;
            try
            {
                authToken = GetAuthToken(code);
                FacebookClient app = new FacebookClient(authToken);
                dynamic user = app.Get("me");
                var id = user.id;
                var args = new Dictionary<string, object>();
                args["message"] = "Test Wall Post";
                args["caption"] = "Test Caption";
                args["description"] = "Test Description";
                args["name"] = "Test Name";
                //args["picture"] = "[your image URL]";
                //args["link"] = "[your link URL]";

                app.Post("/me/feed", args);
                return string.Empty;

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error getting the Facebook authentication token. {0}", ex);
                return string.Empty;
            }
        }

Thanks!

[Edit] @OffBySome I set up a rough test using the facebook Javascript SDK and I set it to display: 'touch' but it still pops up in my safari iphone user agent. I used this

attachment: {
                title: '<my title>',
                caption: '<my caption>',
  开发者_Go百科              description: (
                        <my description>
                    ),
                name: '<name>',
                link:  '<link>',
                display: 'touch', },

But none of these attachments get added to my wall posts. Am I doing it wrong? Dialogs: Fb.Ui http://developers.facebook.com/docs/reference/javascript/#xfbml


Easiest for this would be to use the Facebook javascript sdk and use the FB.ui dialog to allow the user to share. You can set display=touch or display=wap for a mobile optimized dialog.

0

精彩评论

暂无评论...
验证码 换一张
取 消