jeudi 27 avril 2017

Issues in Implementing Facebook Share API on my web application

I'm currently trying to figure how I can implement the Facebook Share API on my application. I have been getting errors even though I have implemented it correctly. Here is so far what I've done. I have copied the following code below from the Facebook Application that I have just created and placed it on the Web Application that I'm currently building.

  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'APP ID',
      xfbml      : true,
      version    : 'v2.9'
    });
    FB.AppEvents.logPageView();
  };

  (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 = "//connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));


  $('#facebook').on('click', function() {

      // FB.ui({
      //   method: 'feed',
      //   link: 'http://localhost/es/',
      //   caption: 'An example caption',
      // }, function(response){});

      FB.ui({
        method: 'share',
        display: 'popup',
        quote: 'test',
        href: 'http://nytimes.com/'
      }, function(response){});
  })

I tried testing it and right now I got this error.

enter image description here

This is the web application that I'm currently developing and is running on Python/Angular.

I made a separate page on my localhost using XAMPP and also using the same Facebook Code. And to my surprise it works.

enter image description here

If you look at the settings on my Facebook Application. I did not have to add the url in App Domains and also Site URL. I tried placing the IP address of my Web App but it won't allow it. I even disabled the pop-up blocker that is installed on my browser

enter image description here




Aucun commentaire:

Enregistrer un commentaire