如何从facebook javascript sdk隐藏facebook帖子链接/标题参数

如何从facebook javascript sdk隐藏facebook帖子链接/标题参数,facebook,facebook-javascript-sdk,Facebook,Facebook Javascript Sdk,我正在使用Facebook JavaScript SDK在不同的Facebook用户页面上发布我的自定义HTML表单 我的HTML表单包含以下字段 但我面临的问题是,当用户没有在字段(空白)中输入链接URL,并在图片URL字段框中输入图片URL时,facebook会在墙上显示图片主机名,而不是显示空白或无链接URL/图片URL。 我用于在页面上发布我的状态的代码 FB.api('/' + d + '/feed', 'post', {

我正在使用Facebook JavaScript SDK在不同的Facebook用户页面上发布我的自定义HTML表单

我的HTML表单包含以下字段

但我面临的问题是,当用户没有在字段(空白)中输入链接URL,并在图片URL字段框中输入图片URL时,facebook会在墙上显示图片主机名,而不是显示空白或无链接URL/图片URL。

我用于在页面上发布我的状态的代码

FB.api('/' + d + '/feed', 'post', {
                                message: my_message,
                                link: url,
                                name: title,
                                picture: picUrl,
                                description: desc,
                                access_token: b.access_token
                            }, function (a) {
                                if (!a || a.error) {
                                    alert('Error occured')
                                } else {
                                    alert('Message Posted Successfully.')
                                }
                            })
链接:url

图片:picURL

我试图通过评论“link”参数提交,但facebook仍然在墙上显示图片主机URL地址


因此,我需要知道如何停止在墙上显示图片主机URL地址,如果用户没有在Facebook帖子中提交链接URL,您可以将此链接作为标题引用,只需在标题参数中保留一些空间即可。如果您使用的是string.empty,则它将打印您的IP地址/域名

在这里,我为您提供的样本代码

<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function () {
        FB.init({
            //Get your Facebook API Key from Web.config
            appId: '<%=ConfigurationManager.AppSettings["FB_API_KEY"].ToString() %>',
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });
    };

    (function () {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
</script>
我将图像URL存储到ID为hfImageURL的HiddenField中,并将其提供给帖子的picture属性

就这样,你可以检查代码。。。为我工作很好


祝您有愉快的一天…

请尝试
caption
参数。Facebook说“贴子标题(只有指定了链接时才能使用)”如果没有指定链接,那么墙上显示的图片URL?它还说,
picture
只能在给出
link
时使用。谢谢你们的帮助,但我的问题是,在用户在指定字段中输入URL之前,我不想显示任何类型的URL。但我无法从上面提供的链接中获得解决方案。对于普通帖子,您可以只发布一条消息,也可以发布一条消息和一个链接,并且该链接可以有描述、缩略图等。只有消息和图片,没有链接,是不可能的。
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function () {
        FB.init({
            //Get your Facebook API Key from Web.config
            appId: '<%=ConfigurationManager.AppSettings["FB_API_KEY"].ToString() %>',
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });
    };

    (function () {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
</script>
function postToFacebook() {

    var POST_NAME = "Post Name";
    var POST_DESCRIPTION = "Post Description";
    var POST_MESSAGE = "";


    //Here I am Leaving some space in the Caption to avoid link name
    var POST_CAPTION = "  ";


    var body = 'Reading Connect JS documentation';
    FB.login(function (response) {
        if (response.authResponse) {
            FB.api('/me/feed', 'post', { body: body, message: POST_MESSAGE, caption: POST_CAPTION, name: POST_NAME, description: POST_DESCRIPTION, picture: document.getElementById('hfImageURL').value }, function (response) {
                if (!response || response.error) {
                    //alert(response.error);
                    alert('Image is not posted.');
                } else {
                    alert('Image is posted.');
                }
            });
        }
    }, { scope: 'offline_access,publish_stream' });
}