简体   繁体   English

在WordPress网站上的Javascript中自定义Facebook共享对话框

[英]Customize Facebook share dialog from within Javascript on WordPress site

I'm trying to implement a Facebook sharer dialog. 我正在尝试实现一个Facebook共享器对话框。 Here is the scenario: 这是场景:

I've developed a quiz on a single WordPress page using Gravity Forms multipage. 我已经使用Gravity Forms多页在单个WordPress页面上开发了一个测验。 There is also custom jQuery that tallies the quiz score progressively. 还有一个自定义的jQuery,可以逐步计算测验分数。 Once the quiz is completed the score determines what content is displayed (the result). 测验一旦完成,分数就会确定要显示的内容(结果)。

I want to provide a link within the quiz page results so the user can share their results on their Facebook page. 我想在测验页面结果中提供一个链接,以便用户可以在其Facebook页面上共享其结果。 The results text should be different depending on how they scored. 结果文本应根据评分方式有所不同。 Also, the shared image is to be different depending on the user's score. 另外,共享图像将根据用户的分数而不同。 The link to the quiz will always be the same. 测验的链接将始终相同。

A couple of years ago (or less?) this was easy to do since the title, description, and image could all be specified in the Facebook sharer URL, but things have changed and now it appears to be a requirement that OG meta tags are included in the header of the page. 几年前(或更短的时间),这很容易做到,因为标题,描述和图像都可以在Facebook共享者URL中指定,但是情况已经发生变化,现在看来,要求将OG元标记包含在页面标题中。

Using jQuery/Javascript, how is this done now? 使用jQuery / Javascript,现在如何完成? I've been reading answers to posts here on SO, but many of them are old and Facebook no longer supports those methods. 我一直在阅读关于SO的帖子的答案,但是其中很多都是过时的,Facebook不再支持这些方法。 Other answers just don't cover my scenario completely. 其他答案只是不能完全涵盖我的情况。

I can't tell exactly whether I need a Facebook App Id or if I can get by without one (preferably). 我无法确切地说出我是否需要一个Facebook App ID,或者我是否可以没有一个(最好)。

Also, is it possible to load the Facebook share dialog with a custom title, description and image without having og meta tags in the header? 另外,是否可以在自定义标题,描述和图像的Facebook共享对话框中加载标题无需og meta标签? I ask this because this is on a WordPress site and I don't have access to the headers unless I create a new page template or install a plugin and most plugins set meta tags sitewide. 我问这个问题是因为这是在WordPress网站上,除非我创建新的页面模板或安装插件,并且大多数插件在站点范围内设置了元标记,否则我无权访问标头。 I need them only on this one page... 我只需要在这一页上...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM