Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Kahn 602 posts 506 karma points
    Jan 21, 2013 @ 16:56
    Thomas Kahn
    1

    Post on Facebook wall when node is published?

    Hi!

    I'm trying to figure out a way to accomplish this:

    1. User fills out a Contour form. As a part of this form, the user can connect with Facebook Connect to give their permission for a Facebook App to post messages in their feed.
    2. When the form is submitted, the data is saved as an (unpublished) umbraco page.
    3. The editor reviews and edits the unpublished page.
    4. When the editor saves and publishes I want to auto-post a message in the feed of the user that filled out the form.

    I have a setup similar to this working, except Facebook isn't involved in this setup. Instead a mail is sent to the user's inbox when the page is published.

    My concerns are: is it possible to send a message to a user's feed directly from the server using ASP.NET? Don't we need some sort of session? Are there any working and stable frameworks for working with Facebook Connect/Graph API for C#/ASP.NET?

    Thanks in advance!

    /Thomas

     

  • Sébastien Richer 194 posts 430 karma points
    Jan 22, 2013 @ 23:25
    Sébastien Richer
    0

    Hi Thomas,

    I often hook into the save and publish node events to perform some operations. Here is how I hook into them. I have this file that gets compiled into a .dll that I put into my /bin folder. It's named "NodeHooks.cs". In there :

    using System;
    using System.Linq;
    using Umbraco.Core;
    using Umbraco.Web;
    using umbraco.BusinessLogic;
    using umbraco.businesslogic;
    using umbraco.cms.businesslogic;
    using umbraco.cms.businesslogic.web;
    
    namespace MyNamespace
    {
        public class NodeHooks : IApplicationEventHandler
        {
    
            public void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
                Document.New += DocumentNew;
                Document.AfterPublish += AfterPublish;
            }
    
            public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
            }
    
            public void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
            }
    
            static void AfterPublish(Document sender, PublishEventArgs args)
            {
                if (sender.ContentType.Alias == "OfSomeType")
                {
                    // Do stuff
                }
            }
    
            static void DocumentNew(Document sender, NewEventArgs e)
            {
                if (sender.ContentType.Alias == "OfSomeType")
    { // Do stuff } } } }

     

    Inside those events, you can access node properties with sender. So I think you could try and code some "PushToFacebook" functionnality in there, but I'm unfamiliar with what would be needed to do that. But if this works for you, post the details here I would be very interested!

    Hope this helps!

    Seb

  • Thomas Kahn 602 posts 506 karma points
    Jan 23, 2013 @ 08:14
    Thomas Kahn
    0

    Hi Seb!

    I have the event part sorted out, but thanks for posting an example!

    The problem I'm facing has more to do with Facebook and the integration of Facebook with Umbraco. In our case it could take a long time (hours/days) between the time the user connects with Facebook and gives permissions and the time when the node is published and the message should be posted to facebook.

    I've found an article on Facebooks developer site that talks about something called an App Token which doesn't expire:

    https://developers.facebook.com/docs/technical-guides/opengraph/publishing-with-app-token/

    ...and it seems like this kind of token can be used to post stuff to a user feed eventhough the user is not currently logged in to Facebook. More about the different app tokens can be read here:

    https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/

    Ok - so there might be a way to get permission to do the actual post. The second part of my question has to do with the actual method of interacting with Facebook. Normally when we do Facebook integration on a website we use the JavaScript SDK. In this case I don't think that's possible since all that will be executed is ASP.NET code on the server, like in the example Seb posted. So I guess this means that we'll need to do authentication and interaction with Facebook though 100% ASP.NET code(?) Is there anyone who has some experience of this? Are there any good libraries out there that we shoudl try? Are there libraries that we should stay away from?

    /Thomas

Please Sign in or register to post replies

Write your reply to:

Draft