Search code examples
phpfacebookfacebook-javascript-sdkfacebook-wallfacebook-canvas

Post to Wall from tab with insights / counter / statistics


I am looking for a solution where a user will be visiting a Facebook tab/canvas app where a Share type button will appear. When they click on the button it will publish to their wall AND that there is a way to track the number of times that it is published on a user's wall.

Is there a solution for this that exists where there could be insights, stats or even a counter after a user clicks to share on their wall? Looking for a Javascript/PHP solution.


Solution

  • You will want to use the feed dialog available in the JavaScript SDK (https://developers.facebook.com/docs/reference/dialogs/feed/).

        var obj = {
          method: 'feed',
          link: 'https://developers.facebook.com/docs/reference/dialogs/',
          picture: 'http://fbrell.com/f8.jpg',
          name: 'Facebook Dialogs',
          caption: 'Reference Documentation',
          description: 'Using Dialogs to interact with users.'
        };
    
        function callback(response) {
          // do something with "response.post_id" here to save it in your database
          //
        }
    
        FB.ui(obj, callback);
    

    In the callback, just store the post_id in your database and you can track it perfectly.

    Happy coding!