简体   繁体   中英

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

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>',
                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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM