简体   繁体   中英

Customize Facebook share dialog from within Javascript on WordPress site

I'm trying to implement a Facebook sharer dialog. Here is the scenario:

I've developed a quiz on a single WordPress page using Gravity Forms multipage. There is also custom jQuery that tallies the quiz score progressively. 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. 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.

Using jQuery/Javascript, how is this done now? I've been reading answers to posts here on SO, but many of them are old and Facebook no longer supports those methods. 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).

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? 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. I need them only on this one page...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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