可能的重复:
Facebook Sharer 如何选择图像?
我正在尝试定义正确的路径对于我网站的 Open Graph 元标记中的产品图像,这样当有人单击嵌入的“赞”或“发送”按钮时,他们所在的特定产品页面的图像将显示在 Facebook 中。
我的网站在基于 php 的定制电子商务解决方案上运行。它的 head 部分完全是用 php 生成的,这使得(对我来说)编写 Open Graph 元标记变得格外困难。
到目前为止,我的代码是:
echo("\t<meta property=\"og:image\" content=\"{$config["absolute_url"]}/media/productimages/{$data["imageid"]}/{$data["extension"]}\" />\n");
... 它只在 Facebook 的开发人员 linter 中显示空白图像,当在我的网站上单击“赞”或“发送”按钮时根本不显示图像。
我已经尝试了很多(垃圾)解决方案,但没有任何效果 - 我是 php 新手,正在苦苦挣扎!构建我们网站的开发人员无法帮助我,而且目前转向另一款电子商务购物车在经济上也不可行,所以我对这个购物车很不满意。
任何帮助、提示或建议将不胜感激。
谢谢! =]
2011 年 9 月 13 日添加:
如果有帮助,这里是我网站头部的全部 OG 元标记:
// Output Facebook Open Graph Meta Tags
echo("\t<meta property=\"og:title\" content=\"".page_title()."\" />\n");
echo("\t<meta property=\"og:type\" content=\"article\" />\n");
echo("\t<meta property=\"og:site_name\" content=\"ElectricPlanet.co.uk\" />\n");
echo("\t<meta property=\"fb:app_id\" content=\"135246374547713\" />\n");
echo("\t<meta property=\"og:image\" content=\"{$config["absolute_url"]}/media/productimages/{$data["imageid"]}.{$data["extension"]}\" />\n");
echo("\t<meta property=\"og:url\" content=\"{$config["absolute_url"]}".seo_url_encode($productdata['title'])."\" />\n");
所有其他 OG 标记都工作正常,除了 og:url 标记,我也使用它目前很困惑。 =S
这是输出图像的片段:
echo("<img src=\"{$config["absolute_url"]}/media/productimages/{$data["imageid"]}_product.{$data["extension"]}\" height=\"{$config["product_image_height"]}\" width=\"{$config["product_image_width"]}\" id=\"mainProductImage\" alt=\"{$productdata["title"]}\" />");
这是典型产品页面的链接:
http://www.electricplanet.co.uk/product/26/211/Mathmos-Astrobaby-Lava-Lamp
大感谢任何为我看到这个问题的人 - 即使我们没有解决这个问题,我也非常感激。我以前从未真正寻求过编码帮助 - 我的工作模式是在大约十天的时间内紧张地“试错”,直到我解决某些问题或将我的“计算机扔到墙上”! - 虽然我已经在 html、css 和一点 javascript 方面自学达到了不错的水平,但当涉及到 php 时,我完全超出了我的能力范围。
再次感谢 Stack Overflow 专家!
干杯,罗斯
Possible Duplicate:
How does Facebook Sharer select Images?
I'm trying to define the correct path for product images within my site's Open Graph meta tags so when someone clicks the embedded Like or Send button, an image from the specific product page they're on will display in Facebook.
My website is running on a bespoke php-based e-commerce solution. Its head section is entirely generated in php, making it extra difficult (for me) to write the Open Graph meta tags.
The code I have so far is:
echo("\t<meta property=\"og:image\" content=\"{$config["absolute_url"]}/media/productimages/{$data["imageid"]}/{$data["extension"]}\" />\n");
... which just displays a blank image in Facebook's developer linter, and no image at all when Like or Send buttons are clicked on my website.
I've tried lots of (rubbish) solutions but nothing works - I'm new to php and struggling big-time! The developer who built our site is not available to help me, and moving to another e-commerce cart isn't financially viable at present, so I'm up sh!t creek sans paddle with this one.
Any help, tips or advice would be MASSIVELY appreciated.
Thanks! =]
Added 13/09/11:
In case it helps, here's the whole chunk of OG meta tags from my site's head section:
// Output Facebook Open Graph Meta Tags
echo("\t<meta property=\"og:title\" content=\"".page_title()."\" />\n");
echo("\t<meta property=\"og:type\" content=\"article\" />\n");
echo("\t<meta property=\"og:site_name\" content=\"ElectricPlanet.co.uk\" />\n");
echo("\t<meta property=\"fb:app_id\" content=\"135246374547713\" />\n");
echo("\t<meta property=\"og:image\" content=\"{$config["absolute_url"]}/media/productimages/{$data["imageid"]}.{$data["extension"]}\" />\n");
echo("\t<meta property=\"og:url\" content=\"{$config["absolute_url"]}".seo_url_encode($productdata['title'])."\" />\n");
All the other OG tags are working fine, except for the og:url one, which I'm also currently flummoxed by. =S
Here's a snippet from where images are output:
echo("<img src=\"{$config["absolute_url"]}/media/productimages/{$data["imageid"]}_product.{$data["extension"]}\" height=\"{$config["product_image_height"]}\" width=\"{$config["product_image_width"]}\" id=\"mainProductImage\" alt=\"{$productdata["title"]}\" />");
And here's a link to a typical product page:
http://www.electricplanet.co.uk/product/26/211/Mathmos-Astrobaby-Lava-Lamp
Big kudos to anyone who takes a look at this for me - I'm extremely grateful, even if we don't crack this issue. I've never actually asked for coding help before - my MO is to 'trial-and-error' stressfully for about ten days until I either solve something or throw my 'puter against a wall! - but while I've managed to self-teach myself to an ok level in html, css and a little javascript, I'm completely out of my depth when it comes to php.
So thanks again in advance, Stack Overflow gurus!
Cheers, Ross
发布评论
评论(1)
可能不是斜线,但点一定在这里?
{$data["imageid"]}/{$data["扩展名"]}
May be not slash, but dot must be here?
{$data["imageid"]}/{$data["extension"]}