我正试图通过网址在Facebook上分享链接。我得到了共享工作,但是我没有加载redirectURI,而是关闭弹出窗口。我的代码:
function fb_share(url) { window.open(url,"share_window","width=400,height=300"); }
...
fb_share('http://www.facebook.com/dialog/feed?app_id=128000000000&link=http%3a%2f%2fwww.facebook.com%2fapps%2fapplication.php%3fid%128000000000%26sk%128000000000&picture=http://www.google.com/images/nav_logo83.png&name=name&description=description&redirect_uri=http%3a%2f%2fwww.facebook.com%2fapps%2fapplication.php%3fid%3d128398017257108%26sk%3dapp_128000000000&display=popup')
答案 0 :(得分:10)
我写了一个可以用作redirect_uri的页面,它将通过javascript关闭弹出窗口:http://www2.highpoint.edu/close_popup.php
查看源代码以查看一些简单的HTML:
<!doctype html>
<html>
<h3>Thank you!</h3>
<a href="javascript:close();">Close this window</a>
<script type="text/javascript">
close();
</script>
</html>
当用作Facebook对话框的回调时,它可以正常工作。
答案 1 :(得分:0)
重定向的网址包含参数 post_id ,因此您可以检查它并在找到它时关闭窗口:
if (window.location.search.indexOf('post_id') == 1){
window.close();
}