0
我正在为我的应用开发Facebook发布到墙功能。我正在使用Facebook Javascript SDK。但是,当我通过单击链接调用postToFeed()函数时,它可以与iframe完美协作。但是,如果我想以某种其他方式加载(例如body onload),则iframe会显示错误“发生错误,请稍后再试”。我已经提供了带有FB.ui的access_token,它可以消除会话问题,但是如果不点击链接,仍然无法工作。以下是我的代码: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>
<?php
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&grant_type=client_credentials&redirect_uri=MY_REDIRECT_URI";
$token = file_get_contents($token_url);
?>
<script>
FB.init({appId: "MY_APP_ID", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'stream.publish',
display: 'iframe',
access_token: '<?php echo $token;?>',
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>
我的应用程序现在处于沙盒模式。但我想这不是问题。请帮助我。谢谢
感谢您的回复。我已经整理出来了...... :) – 2012-02-14 08:05:14
请问你能解决这个问题吗? – DMCS 2012-02-14 14:15:17
从哪里我可以关闭这? – 2012-02-20 09:40:09