Facebook feed dialog - feed dialog not working as expected
I have been trying this for the past couple of days but I couldn't get it
worked. I am trying to post on a users wall using feed dialog when he
enters an app for the first time using javascript SDK. Below is the code:
<div id="fb-root"></div>
<script type="text/javascript">
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
window.fbAsyncInit = function() {
FB._https = (window.location.protocol == "https:");
FB.init({
appId: '<?php echo $config["apikey"]; ?>',
frictionlessRequests : true,
status: true,
cookie: true,
oauth: true,
xfbml: true
});
FB.Event.subscribe('edge.create', function(href, widget) {
// Do something, e.g. track the click on the "Like" button here
addChipsLike();
});
};
var ffuname = '';
var lluname = '';
function post_to_wall()
{
FB.api('/me', function(response)
{
ffuname = response.first_name;
lluname = response.last_name;
});
//alert('inside');
FB.ui({
method: 'feed',
link: 'somelink',
picture: 'somepicture.png',
name: 'Name of the link',
caption: 'CaptDescription'
}, doitnow);
}
</script>
I check whether the user is new or not and if he is a new user I call the
post_to_wall() function inside php code.
The Problem is sometimes the feed dialog is loading but i couldn't get the
username, and sometimes the feed dialog is loading but "An error occurred.
Please try again later" in it and, sometimes the feed dialog is not at all
loading with an error in console, say "FB is not defined" in the line
FB.api.
Could anybody please help me to fix this issue? Thanks in advance...
No comments:
Post a Comment