【问题标题】:Open Graph produces "http://invalid.invalid/" for shared pageOpen Graph 为共享页面生成“http://invalid.invalid/”
【发布时间】:2014-11-21 01:43:08
【问题描述】:

我正在尝试让 FB、Twitter 和 Google+ 为我的网站生成正确的数据。到目前为止,当我点击 FB 分享按钮时,我收到一条消息,上面写着“http://invalid.invalid/”。我以为我按照说明进行了操作,但也许我遗漏了一些东西。有人可以帮帮我吗?

<html <?php language_attributes(); ?> xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Open Graph data -->
    <meta property="og:image" content="<?php bloginfo( 'template_url' ); ?>/img/share.jpg"/>
    <meta property="og:url" content="<?php bloginfo( 'url' ); ?>"/>
    <meta property="og:title" content="Site Title"/>
    <meta property="og:description" content="Site Description"/>

    <!-- Twitter Card data -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" content="Site Title">
    <meta name="twitter:description" content="Site Description">
    <meta name="twitter:image:src" content="<?php bloginfo( 'template_url' ); ?>/img/share.jpg">

    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <link href="//fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet">
    <link href="http://fonts.googleapis.com/css?family=Just+Another+Hand" rel="stylesheet">

    <?php mp3j_addscripts(); ?>
    <?php wp_head(); ?>
</head>

HTML

<div id="sharing">
    <a target="_blank" class="fb_share" href="http://www.facebook.com/share.php?u=<?php bloginfo( 'url' ); ?> /&title=<?php the_title(); ?>" title="Share on Facebook"></a>
    <a target="_blank" class="twitter_share" href="http://twitter.com/home?status=<?php the_title(); ?>+<?php bloginfo( 'url' ); ?>" title="Share on Twitter"></a>
    <a target="_blank" class="gplus_share" href="https://plus.google.com/share?url=<?php bloginfo( 'url' ); ?>" title="Share on Google Plus"></a>
</div>

【问题讨论】:

  • 你有我们的测试链接吗?
  • @luschn 是的,刚刚在上面的帖子中包含了一个。分享链接位于右上角。

标签: wordpress twitter facebook-opengraph


【解决方案1】:

Open Graph 标签看起来不错:

https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fstaging.keebs.com%2F

sharer.php 仅将 URL 作为参数,所以这是正确的:

https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fstaging.keebs.com

【讨论】:

  • 我只是将其更改为那个,但当我尝试分享时它仍然显示http://invalid.invalid/。但我意识到它在 linter 中看起来是正确的。那到底是怎么回事?
  • 您仍然包含标题,并且网址中也有空格。删除这部分:“ /&title=Welcome to The Mobile Mix”
猜你喜欢
  • 2015-09-28
  • 2011-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-30
  • 2012-01-15
  • 2011-03-28
相关资源
最近更新 更多