FB.ui共享设置标题,消息和形象 [英] FB.ui share set the title, message and image

查看:195
本文介绍了FB.ui共享设置标题,消息和形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FB.ui来分享一个页面到Facebook,我正在设置标题和消息(图像,如果可能,但不重要)。我在我的网站标题中有这个

 < meta property =og:titlecontent =你的标题在这里/> ; 
< meta property =og:descriptioncontent =your description here/>

我的JavaScript代码是

  FB.ui({
method:'share',
href:document.URL,
},function(response){

// TODO正确的响应处理
log(response);
if(typeof response!='undefined'){
alert('感谢分享');
}
});

从我读过的我只需要og:titleand og:description来设置标题和消息,但这似乎不起作用。



目前的标题是来自部分标题的一部分,或图像上的alt标签,以及消息

解决方案

元数据可能会被Facebook缓存。尝试在Facebook调试器中输入您的网址: https://developers.facebook.com/tools/debug/



这将清除缓存。



对于图像使用:

 < meta property =og:imagecontent =http:// yourimage> 

Facebook建议使用最小大小为1200x630像素的图像


I'm using FB.ui to share a page to Facebook and I'm trying to set the title and message (image if possible but not important). I have this in my site header

<meta property="og:title" content="Your title here" />
<meta property="og:description" content="your description here" />

And my javascript code is

FB.ui({
      method: 'share',
      href: document.URL,
    }, function(response){

        //TODO Proper response handling
        log(response); 
        if (typeof response != 'undefined') {
            alert('Thanks for sharing');
        }
    }); 

From what I've read I just need to og:titleand og:description to set the title and message, but that doesn't seem to work.

Current the title is either coming from part of the part title, or an alt tag on an image, and the message is being populated from just a random paragraph tag.

解决方案

The meta data might be cached by Facebook. Try entering your url in the Facebook debugger: https://developers.facebook.com/tools/debug/

This will clear the cache.

For image use this:

<meta property="og:image" content="http://yourimage">

Facebook recommends using images with a min size of 1200x630 pixels

这篇关于FB.ui共享设置标题,消息和形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆