问题
I've been using the facebook feed dialog on my website for a while but one day it suddenly stopped working. Facebook support says everything works. From every machine I've tried, it clearly doesn't. If you are logged in and have given the app permission, then the dialog does not pop up anymore when you click on the link.
edit: Once the dialog pops up, could you try posting something? The first time should work. Then try to refresh the page (or even restart the browser, make sure you're logged into facebook) and try to post again. Does it work the 2nd time around? /edit
You can try it directly here: Clicky
I've tried to copy the sample code from the facebook documentation directly and it still doesn't work for me. Here's the sample code from facebook:
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
and here is my code:
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "185521851465588", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
Any help would be greatly appreciated!
Update: I think I found something: if you go to this page first and hit "Post your results", accept the permissions and go back to the test page here, then the dialog stops working again.
回答1:
The link you provided works for me too. However, try adding href="#"
to your <a>
tag to make it look like a correct link.
回答2:
If you are logged in and have given the app permission, then the dialog does not pop up anymore when you click on the link.
Where do I give your app permissions? I’m not asked for any on the page you provided. It just opens the feed dialog when I click on your link.
If something else is necessary to reproduce the problem (giving your app permissions), please provide more info on how to get there.
来源:https://stackoverflow.com/questions/10908904/feed-dialog-fbui-facebook-ui-is-not-working