Facebook Javascript SDK Feed 对话框显示空白 window

Facebook Javascript SDK Feed Dialog showing blank window

我在我的页面上使用 Facebook Javascript SDK 到 post,我已经在这里阅读了一些相关内容:Facebook feed dialog: allow user to select destination page or group 所以我一直在使用这段代码到目前为止:

$("button#shareOn").on('click',function(event){
    event.preventDefault();
    
    var _parentForm=$(this).parents('form:first');
    var _pageSelect=_parentForm.find("select[name='pagesList']");
    var _pID=_parentForm.find("#pID").attr('value');
    var _vURL=_parentForm.find("#_vURL").attr('value');
    
    FB.ui({
        app_id:app_id,
        method: 'feed',
        from: _pageSelect.val(),
        name: 'Title',
        caption: 'Subtitle - 26/02/2013',
        description: 'My text',
        link: _vURL,
    },function(response){
        console.log(response);
    });

});

其中 _pageSelect.val() 是我要在其中尝试访问的页面的 ID post,_vURL 是 url ( youtube link )我想分享...问题是当我点击按钮时,window 打开,但实际上是空白的。

通过打开 Google Chrome 的开发控制台,有时我会看到与 window 相关的 500 内部服务器错误,有时它只会出现完全空的,但我可以弄清楚到底是什么原因造成的。
我也试过 urlencode 来自 PHP 的 url 或来自 Javascript 的 encodeURIComponent,但没有任何改变。

有时 window 只出现标题,副标题和描述,所以我猜 link 应该是错误的,但我知道 Facebook JS SDK 用于编写 Link not properly formatted 或类似 API error (100).

更新

Feed 对话框似乎已开始协作,但仍未按预期工作。这是更新后的代码:

$("button#shareOn[name='shareVideo']").on('click',function(event){
    event.preventDefault();
    
    var _parentForm=$(this).parents('form:first');
    var _pageSelect=_parentForm.find("select[name='pagesList']");
    var _pID=_parentForm.find("#pID").attr('value');
    var _vURL=_parentForm.find("#_vURL").attr('value');
    var options={
        app_id:app_id,
        method:'feed',
        from:_pageSelect.val(),
        link:_vURL,
        caption:'test'
    }
    
    console.log(options);
    
    FB.ui( options, function(response){});

});

打开window,但有时是空白,有时显示一个link,不是视频的url,只是www.youtube.com。我一直在尝试使用 Facebook URL 调试器,它向我展示了我使用的 URL 实际上是正确的。但是提要对话框不起作用

所以,我得到了答案,这并不是我所期待的,但至少它有效。由于 Facebook 文档没有指出这一点,我找到了 sharer 方法,我在 Javascript 函数中调用它。 所以,这是代码:

$("button#shareOn[name='shareVideo']").on('click',function(event){
    event.preventDefault();

    var _parentForm=$(this).parents('form:first');
    var _pageSelect=_parentForm.find("select[name='pagesList']");
    var _pID=_parentForm.find("#pID").attr('value');
    var _vURL=_parentForm.find("#_vURL").attr('value');
    var leftPosition, topPosition;
    var windowFeatures = "status=no,height=" + 400 + ",width=" + 300 + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";

    leftPosition = (window.screen.width / 2) - ((300 / 2) + 10);
    topPosition = (window.screen.height / 2) - ((400 / 2) + 50);

    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(_vURL),'sharer', windowFeatures);
    return false;
});

顺便说一句,我不喜欢这种方法,但它似乎是完成我想做的事情的唯一方法。现在我只需要知道如何获得共享功能的结果(如果 post 被共享或不共享)。

希望这会对某人有所帮助:)