【问题标题】:Google plus web share button not sharing dynamic og tags谷歌加网络共享按钮不共享动态 og 标签
【发布时间】:2016-01-24 02:48:19
【问题描述】:

我正在尝试使用 google plus 分享按钮分享一些活动。我面临的问题是当我尝试通过使用内容被硬编码的 og 标签来共享特定事件时 例如:

<meta property="og:title"  content="My Title">
<meta property="og:image" content="Awesome event">
<meta property="og:description" content="http://exqlusiv.com/wp-content/uploads/2012/08/tomorrowland-2012-video-live-sets-aftermovie.png"> 

然后使用https://developers.google.com/+/web/share/ 给出的代码分享它,它工作正常,但问题是当我将变量传递给 og 标签的内容时,比如

<meta property="og:title" content="<?php echo $title?>" />
<meta property="og:image" content="<?php echo $image?>" />
<meta property="og:description" content="<?php echo $description?>" />

谷歌分享按钮未检测到标签,无法正确分享内容。我真的被困在这个..

任何建议,

谢谢。

【问题讨论】:

  • 您可能必须在标签处使用 htmlspecialchars 以防止错误。否则您的代码就可以了
  • 感谢您的回复,但它没有工作:(
  • 您的 HTML 代码有效吗?
  • 变量$image 包含域?因为否则将无法正常工作。失败:&lt;meta property="og:image" content="/img/name.jpg" /&gt; 正确:&lt;meta property="og:image" content="http://domain.com/img/name.jpg" /&gt;

标签: php google-plus


【解决方案1】:

确保您已通过直接访问页面和使用Google Rich Data Testing Tool 验证数据已正确填写。虽然 Google 共享通常可以识别 og 数据,但您可能还需要考虑添加 @ 987654322@ Google 似乎更擅长处理。

【讨论】:

  • 尽管我遇到了同样的问题(描述未填充),即使存在 Schema.org 数据,如&lt;meta itemprop="description" content="text text" /&gt;
  • @TopherHunt - 您可能应该使用尽可能多的细节和示例来创建自己的问题。
【解决方案2】:

对于 Google+,将 ?v=random_string 附加到 URL。 如果您将此想法用于 Facebook 分享,请确保响应中的 og:url 参数与您分享的 URL 匹配。

对于 Facebook,您还可以通过向https://graph.facebook.com 发送帖子请求来强制重新抓取

{id: url,
scrape: true}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多