top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

    Get Free Article Updates

Facebook Login
Site Registration

Smart Facebook Send Message Button

+3 votes
153 views

Many a times you want your webside to share the link with facebook friends as a message to increase the viral effect. Following is the code for the smart way of sharing the link and this code is working on QueryHome (only registered user will see this)

JAVA Script Code

function qh_init_facebook_api (applicationId , ajaxCallback , ajaxCallbackParam ) {
    if (!applicationId) {return false };
    if (typeof (FB) == 'undefined') {
        $.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
            if (!FB.qh_initialized) {
                FB.init({
                      appId: applicationId ,
                      cookie: true,
                      status: true,
                      xfbml: true
                });
                FB.qh_initialized = true ; 
                ajaxCallback(applicationId , ajaxCallbackParam ) ;
            }
        });
    }   
}

function qh_share_link_to_facebook(applicationId , param) { 
    if (!applicationId) {return false };

    qh_init_facebook_api(applicationId ,qh_share_link_to_facebook , param ) ;
    if (typeof (FB) != 'undefined') {
        param.method = 'send' ;
        FB.ui(param);
    }
}

CSS Code

share{
  background-color: #3B5998;
  border: none;
  padding: 10px 10px 10px 10px;
  color:white !important;
  border-radius: 3px;
  cursor:pointer;
  text-decoration:none;
}
share:hover{
  text-decoration:none;
}

HTML Code

<a class="share" onclick="qh_share_link_to_facebook(<app_id>, {link:'<link>' ,})">Facebook Message</a>

app_id is your facebook app_id
link is the link which you want to share

posted Aug 12, 2014 by Salil Agrawal

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

Many a times you want your friends over Facebook for a particular website with some message to increase the viral effect. Following is the code for the smart way inviting and this code is working on QueryHome (only registered user will see this)

JAVA Script Code

function qh_init_facebook_api (applicationId , ajaxCallback , ajaxCallbackParam ) {
    if (!applicationId) {return false };
    if (typeof (FB) == 'undefined') {
        $.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
            if (!FB.qh_initialized) {
                FB.init({
                      appId: applicationId ,
                      cookie: true,
                      status: true,
                      xfbml: true
                });
                FB.qh_initialized = true ; 
                ajaxCallback(applicationId , ajaxCallbackParam ) ;
            }
        });
    }   
}

function qh_invite_facebook_friends(applicationId , param) {
        // reutrn if applications id is not set
        if (!applicationId) {return false };

        // first of all initialize facebook api
        qh_init_facebook_api(applicationId , qh_invite_facebook_friends , param) ;
        if (typeof (FB) != 'undefined') {
                param.method = 'apprequests' ;
                FB.ui(param);
        }
}

CSS Code

invite {
  background-color: #3B5998;
  border: none;
  padding: 10px 10px 10px 10px;
  color:white !important;
  border-radius: 3px;
  cursor:pointer;
  text-decoration:none;
}
invite:hover{
  text-decoration:none;
} 

HTML Code

<a class="invite" onclick="qh_invite_facebook_friends(<app_id>, {message:'<message>' ,})">Facebook Invite</a>

app_id: Your facebook app_id
message: Is the message which you want to share on Invite.

READ MORE
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...