Facebook Sharer - 标题和摘要定制 [英] Facebook Sharer - Title and summary Customization

查看:506
本文介绍了Facebook Sharer - 标题和摘要定制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Django的一个项目中工作,我正在Facebook和Twitter上分享页面



我在Facebook上有问题,我想自定义共享标题和摘要,在共享索引页和任何其他页面时更改文本。



我尝试使用:

 < a href ='http ://www.facebook.com/sharer.php S = 100&安培; 
p [title] = TITLE + TEST&
p [summary] = summary&
p [url] = http:// {{request.META.HTTP_HOST}} {{request.path}}&
p [images] [0] = http://whatever.com/media/img/img_facebook.jpg'
target =_ blank>
< img src ={{STATIC_URL}} img / ico_facebook_small.pngtitle =Facebookalt =Facebook>< / a>

甚至添加:

 < meta property =og:titlecontent =我的标题/> 

我可以更改的只有2件事情是网址显示和图片。 Facebook分享者忽略标题和摘要。我最后一个小时搜索互联网,我没有找到适用于我的解决方案。



任何人都知道Facebook Sharer是否不工作?有没有解决方案的自定义标题和摘要?



谢谢






编辑



现在我使用og元标记,但仍然有问题。我希望每个页面都有不同的标题,我需要通过Javascript获取标题(我通过js更改og:title内容),但是看起来变化的效果太晚了,因为Facebook只得到标题的一部分那是静态的。



我有这样的东西:

 < meta property = og:titlecontent =TitlePage/> 

并通过js更改内容,使其像

 < meta property =og:titlecontent =TitlePage SOMETHINGELSE/> 

更改生效不错,没有问题,但像我说的那样,Facebook没有检测到这种变化。






编辑2



我已经回答了我自己的问题,因为我找到了一个解决方案,以旧的方式进行共享,但需要一个应用程序才能使代码工作。

解决方案

Facebook Sharer没有打开图表元标签



我改变了正确的答案,因为在一个新的项目,我不得不这样做以旧的方式,我终于得到这个代码,通过在Facebook中创建一个简单的应用程序正常工作:



此示例应用程序的信息: Facebook发送对话



APP_ID :Facebook应用标识符

http://www.THEPAGE.com :这将是我的域

  $('#share_button')bind('click',function(e){
e.preventDefault();
var title ='我想要的标题'
var im_url ='url_to_image';
var facebook_appID ='YourFacebookAppID'
url =https://www.facebook.com/dialog/feed?app_id=\"+ facebook_appID +& link =+ encodeURIComponent(http: /www.THEPAGE.com\")+
& name =+ encodeURIComponent(title)+
& caption =+ encodeURIComponent('从MY_PAGE共享)+
& description =+ encodeURIComponent('DESCRIPTION')+
& picture =+ encodeURIComponent(http://www.THEPAGE.com+ im_url)+
& redirect_uri = https://www.facebook.com;
window.open(url);
});

需要Facebook应用程序



要创建您的Facebook应用程序,您需要注册为开发人员并创建应用程序访问下一个链接:



Facebook开发者APPS


I'm working in a project with Django and I'm trying to share pages in facebook and twitter

I have problems on facebook, I want to customize the Title and summary shared, to change the text when you share an Index Page and any other page.

I tried using:

<a href='http://www.facebook.com/sharer.php?s=100&
p[title]=TITLE+TEST&
p[summary]=summary&
p[url]=http://{{ request.META.HTTP_HOST }}{{ request.path }}&
p[images][0]=http://whatever.com/media/img/img_facebook.jpg' 
target="_blank">
<img src="{{STATIC_URL}}img/ico_facebook_small.png" title="Facebook" alt="Facebook" ></a>

and even adding:

<meta property="og:title" content="My Title" />

The only 2 things I can change is the url showed and the image. Facebook sharer ignores title and summary. I search trough internet the last hour and I didn't find any solution that works for me.

Anyone knows if the facebook sharer isn't working anymore ? is there any solution to custom title and summary ?

Thanks


EDIT

Now I'm using og meta tags, but still have a problem. I want that each page has different titles, and I need to get the title via Javascript (I change the "og:title" content via js) but it seems the change take effect too late, because Facebook only get the part of the title that is static.

I have something like:

<meta property="og:title" content="TitlePage" /> 

and change the content via js to make like

<meta property="og:title" content="TitlePage SOMETHINGELSE" /> 

The change takes effect nice and without problems but like I said, facebook doesn't detect that change.


EDIT 2

I've answered my own question because I've found a solution to do the sharing in the old way, but an app is needed to make the code works.

解决方案

Facebook Sharer without Open Graph meta tags

I change correct answer after this long because in a new project, I had to do the same in the old way, and I finally get this code to works fine by creating a simple app in facebook:

Info for this sample apps: Facebook Send Dialog

APP_ID: Facebook app Identifier
http://www.THEPAGE.com: This would be my domain

$('#share_button').bind('click', function(e){
        e.preventDefault();
        var title = 'Title I want';
        var im_url = 'url_to_image';
        var facebook_appID = 'YourFacebookAppID'
        url = "https://www.facebook.com/dialog/feed?app_id="+ facebook_appID +    "&link=" + encodeURIComponent("http://www.THEPAGE.com")+ 
                    "&name=" + encodeURIComponent(title) + 
                    "&caption=" + encodeURIComponent('Shared from MY_PAGE') + 
                    "&description=" + encodeURIComponent('DESCRIPTION') + 
                    "&picture=" + encodeURIComponent("http://www.THEPAGE.com" +im_url) +
                    "&redirect_uri=https://www.facebook.com";
        window.open(url);
    });

Facebook app is needed to do this

To create your facebook app you need to register as developer and create the app visiting the next link:

Facebook Developer APPS

这篇关于Facebook Sharer - 标题和摘要定制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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