facebook共享错误:“;方法“;是FB.ui()的必需参数

facebook share error: "method" is a required parameter for FB.ui()

本文关键字:参数 ui 错误 共享 方法 facebook FB      更新时间:2023-09-26

标题说明了一切。我总是收到这样的错误:"method"是FB.ui()的必需参数。但方法被设置为"feed"

这是因为我目前在我的机器上本地工作,而不是在真正的服务器上吗??该应用程序也在脸书上注册。

知道吗?

<span id='share'>SHARE</span>   
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({appId: '2907534********', status: true, cookie: true, xfbml: true});
    };
    (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);
    }());
</script>
<script type="text/javascript">
    $(document).ready(function(){
            $('#share').click(function(e){
                e.preventDefault();
                FB.ui({
                    method: 'feed',
                    name: 'This is the content of the "name" field.',
                    link: ' http://www.hyperarts.com/',
                    picture: 'http://www.hyperarts.com/external-xfbml/share-image.gif',
                    caption: 'This is the content of the "caption" field.',
                    description: 'This is the content of the "description" field, below the caption.',
                    message: ''
                    });
                });
            });
</script>

$('#share').click(function(e){部分的代码应该进入窗口。fbsynchInit调用确保在将点击事件分配给使用FB的东西之前加载框架。

我用自己的应用程序ID测试了同样的代码,它对我来说很好。唯一的区别是我把名称、标题和描述改为"This",最后我修复了一个语法问题。

你确定这段代码是你的错误来源吗?

  • 您必须在服务器上联机(实际上是服务器)
  • 如果你这行没有Facebook idFB.init({appId:'2907534********',状态:true,cookie:true,xfbml:true});你必须有一个来自这个网址:https://developers.facebook.com/或搜索如何创建facebook应用程序(如何创建facebook应用程序)的示例hyperarts.com/blog/how-create-facebook-application-to-get-an-app-id-for-your-website/
  • 但如果你已经有了facebook id,并且已经知道如何创建应用程序,你必须把代码放在顶部,放在你放在facebook画布上的同一个文件上

例如,如果您在画布中插入(https://www.example.com/test.php)您必须将此代码放在test.php 中

我希望你的问题能很快得到解决!