javascript - Facebook UI,Popup shows An error occurred. Please try later -


ok,i made code,and shows error occurred. please try later when popup comes,and in colsole says : undefined @ "function callback(response) { console.log(response); }"

here's code:

<script> function posttofeed() {   // call api   var obj = {     method: 'feed',     link: 'https://apps.facebook.com/assault_combat/takegift',     picture: 'https://flyandsmash.herokuapp.com/images/gift.png',     name: 'take gift assault combat',     caption: 'https://apps.facebook.com/assault_combat/',     actions: [       {'name': 'get gift', 'link': 'https://apps.facebook.com/assault_combat/takegift'}     ],     description: 'action links awesome.'   };    function callback(response) {     console.log(response);   }    fb.ui(obj, callback); }  </script> 

and btw,when type "fb.init , stuff,it says error on too... (i have imported div fb roots , stuff)

always use asynchronous way load javascript sdk: https://developers.facebook.com/docs/javascript/quickstart

<div id="fb-root"></div> <script>   window.fbasyncinit = function() {     fb.init({       appid      : '{your-app-id}',       status     : true,       xfbml      : true     });      //earliest possibility use fb   };    (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/all.js";      fjs.parentnode.insertbefore(js, fjs);    }(document, 'script', 'facebook-jssdk')); </script> 

about error: none of links added in the obj reachable, might main problem. also, caption cannot have , url, should still work because facebook removes it. it´s better try less parameters, remove action , try without.

i´d write without nested function:

<script> function callback(response) {   console.log(response); }  function posttofeed() {   // call api   var obj = {     method: 'feed',     link: 'https://apps.facebook.com/assault_combat/takegift',     picture: 'https://flyandsmash.herokuapp.com/images/gift.png',     name: 'take gift assault combat',     caption: 'https://apps.facebook.com/assault_combat/',     actions: [       {'name': 'get gift', 'link': 'https://apps.facebook.com/assault_combat/takegift'}     ],     description: 'action links awesome.'   };    fb.ui(obj, callback); } </script> 

make sure call "posttofeed" after initializing sdk, , on user interaction/mouse events. browsers may block popup if don´t use on user events.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -