Subversion Repositories SmartDukaan

Rev

Rev 1736 | Blame | Compare with Previous | Last modification | View Log | RSS feed

FB.init({
        appId  : '179519275432255',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
});

function showFriendSelector()   {
        FB.ui({
                method: 'apprequests',
                title: 'Invite Friends to Phones I Own',
                message: 'This is a cool app to flaunt the phone you own to your friends.'
        });
}

function publishStream(productName, productURL, productImgURL, productDesc)     {
FB.ui({
                method: 'feed',
                name: productName,
                link: productURL,
                picture: productImgURL,
                caption: 'Phones I Own | Saholic.com',
                description: productDesc,
                message: 'Check out the phone I own!'
        },
        function(response) {
                if (response && response.post_id) {
                        showFriendSelector();
                } else {
                        // Post was not published
                }
        });
}

$(function(){
        $('#friendInviter').live('click', function()    {
                showFriendSelector();
        });
        
        $('input.publish-button').click(function()      {
                var id = $(this).attr('id').replace('post-badge-', '');
                var productName = $('#' + id).html();
                var productUrl = $('#url-' + id).html();
                var imageUrl = $('#img-' + id).attr('src');
                var desc = "";

                $('#desc-' + id).children().each(function(i, item){
                        desc += $(item).html() + ', ';
                });
                desc = jQuery.trim(desc);
//              console.log(productName, productUrl, imageUrl, desc);
                publishStream(productName, productUrl, imageUrl, desc);
        });
});