如何与Facebook分享图像"分享对话框"等等

时间:2015-09-16 08:47:49

标签: javascript php html facebook-graph-api

我正在制作一个测试网站,根据测试结果,我想通过脸谱分享一个特定的图像。 问题是所有结果都在同一页面上,这只会向用户显示与他的答案相符的结果。

我知道我必须使用以下og代码将图像设置为共享者的thumbmail:

<meta property="og:image"            content="http://food.png">

问题是,如何选择符合用户结果的图像? 这是我的代码的一部分:

var superman = new insieme(all0, imm[0], des0, desc0, pg0);  \\The imm[i] contains the image relative to each result
var darth_vader = new insieme(all1, imm[1], des1, desc1, pg1);
var jorah_mormont = new insieme(all2, imm[2], des2, desc2, pg2);
var spiderman = new insieme(all3, imm[3], des3, desc3, pg3);
var voldemort = new insieme(all4, imm[4], des4, desc4, pg4);
var vendetta = new insieme(all5, imm[5], des5, desc5, pg5);
var sparrow = new insieme(all6, imm[6], des6, desc6, pg6);
var joker = new insieme(all7, imm[7], des7, desc7, pg7);

var pg = new Array(spiderman, superman, jorah_mormont, darth_vader, voldemort, joker, sparrow, vendetta);  <-- This is the array that contains the results' objects

为了访问用户的结果,我使用一个名为$ res-&gt; random的php变量(它是一个包含不同属性的SQL结果)。

它的使用是这样的:

document.write("<h3>" + pg[<?php echo $res->Random; ?>].allineamento + "</h3>");
document.write("<h4>" + pg[<?php echo $res->Random; ?>].personaggio + "</h4>");
document.write(pg[<?php echo $res->Random; ?>].immagine); <-- Here it shows the image that matches the user's result
. . .

在这里,我向您寻求帮助,如何根据结果为共享设置不同的图像?而且,虽然我们在此,但如何通过以下代码设置不同的标题?

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

提前感谢您的帮助!

0 个答案:

没有答案
相关问题