web-dev-qa-db-ja.com

デバッガを介して特定のリンクを実行するまで、オープングラフのメタデータはFacebookには表示されません。

サイト上のすべての投稿にオープングラフメタデータを追加しましたが、Facebookに投稿リンクを貼り付けようとすると、グラフメタ情報が読み込まれません。

次に、URL をデバッガ/ linter に挿入すると、デバッガ内でも、通常のFacebookへの投稿時にも(以前は動作しませんでしたが)動作します。

この問題は過去に このStack Overflowの質問で 対処されたようです。しかし、その質問はRails環境に関するものです。

その質問では、アプリケーションは同時に複数のhttpリクエストを処理できませんでした。この問題は、delayed_responseという名前のものを使用して、すべてのFacebook APIリクエストをバックグラウンドで処理することで解決されました。

Wordpressを実行しているPHP環境でこれを達成することができ、それによって(うまくいけば)私の問題を解決できる最も簡単な方法は何ですか?

**ユーザがデバッガを通してそれを実行するとすぐに、それが機能するように見えるので、私はこの記事にサンプルリンクを含めませんでした。*

編集 - 投稿ページからのメタタグのサンプル:

<meta property="og:title" content="Budget proposal good news for Ontario drivers - AdvocateDaily.com" />
<meta property="og:type" content="website" />
<meta property="og:image" content="http://build.advocatedaily.com/wp-content/uploads/2013/04/Stacey-Stevens_Colour_NEW_2012-e1354206636925-150x150.jpg" />
<meta property="og:url" content="http://advocatedaily.com/2013/05/budget-proposal-good-news-for-ontario-drivers/" />
<meta property="og:description" content="A provincial budget proposal to reduce auto insurance premiums by an average of 15 per cent is good news for Ontario drivers, but should not come at the cost of benefits available under the policy, says Toronto personal injury lawyer Stacey L. Stevens. &#8220;In response to this announcement, the Insurance Bureau of Canada (IBC) predicts the [...]" />
<meta property="og:site_name" content="Advocate Daily" />

Wp_headに挿入されているPHP:

add_action('wp_head', 'add_fb_open_graph_tags');
function add_fb_open_graph_tags() {
    if (is_single()) {
        global $post;
        if(get_the_post_thumbnail($post->ID, 'thumbnail')) {
            $thumbnail_id = get_post_thumbnail_id($post->ID);
            $thumbnail_object = get_post($thumbnail_id);
            $image = $thumbnail_object->guid;
        } else {
            $image = get_template_directory_uri()."/images/advocatedaily-avatar.png";
        }
        //$description = get_bloginfo('description');
        $description = og_excerpt( $post->post_content, $post->post_excerpt );
        $description = strip_tags($description);
        $description = str_replace("\"", "'", $description);
?>
<meta property="og:title" content="<?php the_title(); ?> - AdvocateDaily.com" />
<meta property="og:type" content="website" />
<meta property="og:image" content="<?php echo $image; ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>" />
<meta property="og:description" content="<?php echo $description ?>" />
<meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>" />
<?php   }
}
function og_excerpt($text, $excerpt){
    if ($excerpt) return $excerpt;
    $text = strip_shortcodes( $text );
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $text = strip_tags($text);
    $excerpt_length = apply_filters('excerpt_length', 55);
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    $words = preg_split("/[\n
     ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    if ( count($words) > $excerpt_length ) {
            array_pop($words);
            $text = implode(' ', $words);
            $text = $text . $excerpt_more;
    } else {
            $text = implode(' ', $words);
    }
    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
2
Orun

まず、これはWordPress固有の質問ではなく、Facebookの質問です。

次に、Facebookはページをキャッシュします。送信するたびにクロールしません。以前にFacebookに送信されたURLがある場合は、以前にOGデータ用に既にクロールされていて、キャッシュに保存されています。後でOGデータを変更しても、すぐに気付くことはありません。ページからではなく、キャッシュから取得しているからです。

Facebook Debuggerは、クローラにページからリアルタイムで引っ張らせることで、キャッシュを更新します。

本当にシンプルです。そのURLが以前にFacebookに投稿されたことがある場合は、そのURLのOGデータを変更してもすぐには有効になりません。 FBが気付くまでに数週間かかるでしょう。デバッガを使用すると、それが上書きされます。

3
Otto

私は同じ問題を抱えていました。あなたがする必要があるのは、Facebookにあなたのコンテンツを再び削るように言うことです。

このリンクに進んでください: https://developers.facebook.com/tools/debug/sharing/ そしてあなたのURLを接続してください。 「もう一度かきます」。クリックして。

私がそれをした後、情報はFacebook上で普通に現れました。

私はあなたのコンテンツを新しく削り取るようにFacebookに指示するもっと直接的な方法があると確信しています、しかしこれもまたうまくいきます。

1
David Gaskin