N
N
newaitix2018-09-08 19:59:14
JavaScript
newaitix, 2018-09-08 19:59:14

Facebook share button?

1. I need such a button to share
5b93fe343e6b4786248532.png
2. I need to know if the user has published a post on the wall or not.
Therefore, the standard buttons do not suit me.
Fb made an api but made an incomprehensible description of this api.
For example, it is written here

FB.ui(
  {
    method: 'share',
    href: 'https://developers.facebook.com/docs/',
  },
  // callback
  function(response) {
    if (response && !response.error_message) {
      alert('Posting completed.');
    } else {
      alert('Error while posting.');
    }
  }
);

But there is no information where the FB object is located anywhere. That is, such a code will cause an error FB.ui is not defined
Since VK and classmates are the absolute opium of fb, nothing is explained there in the same way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey V, 2018-09-08
@dthpth

description of how to connect and initialize the FB object: https://developers.facebook.com/docs/javascript/qu...

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId            : 'your-app-id',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v3.1'
    });
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "https://connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>

PS. I am sure that both VK and OK have detailed documentation. just dig deeper :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question