[ facebook SDK ] dynamics share API

FACEBOOK SHARE DIALOG NO LONGER ACCEPTS CUSTOM PARAMETERS
ref : http://okaypl.us/blog/facebook-share-dialog-longer-accepts-custom-parameters/

Switch to javascript API

<html>
<head>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
  			<link rel="stylesheet" href="style.css" />
  <title>jQuery Example</title>
  <script>
  $(document).ready(function() {
  
  $.ajaxSetup({ cache: true });
  $.getScript('//connect.facebook.net/en_US/sdk.js', function(){
    FB.init({
      appId: '[whatever app id]',
      version: 'v2.7' // or v2.1, v2.2, v2.3, ...
    });     
    //$('#loginbutton,#feedbutton').removeAttr('disabled');
    //FB.getLoginStatus(updateStatusCallback);
    
    $('#share-facebook').click(function(){
        console.log('test');
        
        FB.ui({
            method: 'share_open_graph',
            action_type: 'og.shares',
            action_properties: JSON.stringify({
                object : {
                   'og:url': 'http://astahdziq.in/', // your url to share
                   'og:title': 'Here my custom title',
                   'og:description': 'here custom description',
                   'og:image': 'http://example.com/link/to/your/image.jpg'
                }
            })
            },
            // callback
            function(response) {
            if (response && !response.error_message) {
                // then get post content
                alert('successfully posted. Status id : '+response.post_id);
            } else {
                alert('Something went error.');
            }
        });
  });

}); 
});
  </script>
</head>

<button id="share-facebook">share</button>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s