简体   繁体   English

Facebook Open Graph Cache问题

[英]Facebook Open Graph Cache Issue

I am creating an application that posts information to facebook when a user downloads a specific music album. 我正在创建一个应用程序,当用户下载特定的音乐专辑时,该应用程序向Facebook发布信息。 I have the information parsing correctly. 我有正确的解析信息。 So if a user clicks the download for album 1, it will pull the information and submit to the open graph and show up on facebook, however when I click on the next album button, instead of parsing the information for album 2, it posts the information for album 1 again. 因此,如果用户点击相册1的下载,它将提取信息并提交到打开的图表并显示在Facebook上,但是当我点击下一个相册按钮,而不是解析相册2的信息时,它会发布再次播放专辑1的信息。 I have tried fbrefresh=CAN_BE_ANYTHING but nothing seems to be working. 我试过fbrefresh=CAN_BE_ANYTHING但似乎没有任何效果。 Does anyone have insight to this? 有没有人对此有所了解?

Album 1 Meta Information parse.php?album=The%2520Pink%2520Slip 专辑1元信息parse.php?album =%2520Pink%2520Slip

Album 2 Meta Information parse.php?album=The%2520Sexy%2520Single 专辑2元信息parse.php?album =%2520Sexy%2520Single

Below is the code I am using: 以下是我使用的代码:

<script type="text/javascript">
function postAlbum(album) {
    FB.api('/me/skibsthekid:listen_to?album=http://www.skibsthekid.com/parse.php?album=' + album, 'post',
    function(response) {
        if (!response) { 
            alert('Error Occurred I got no response with ' + $pageURL);
        } else if (response.error) {
            alert('Error Occurred '+ response.error);
        } else {
            alert('Post was successful! Action ID: ' + album);
        }
    });
}

Parse.php Parse.php

<?php
    $title = $_GET['album'];
    foreach(glob('files/'. $title .'/*.jpg') as $art) {
        $art = str_replace(" ", "%20", $art);
        $image = 'http://skibsthekid.com/' . $art;
    }
?> 

<meta property="fb:app_id" content="185324271585974" />
<meta property="og:type" content="music.album" />
<meta property="og:title" content="<?php echo $title; ?>" />
<meta property="og:image" content="<?php echo $image; ?>" />
<meta property="og:url" content="http://www.skibsthekid.com/parse.php?album=<?php echo urlencode($title); ?>&fbrefresh=CAN_BE_ANYTHING" />

The debugger is show each album, so this may just be a temporary caching problem. 调试器显示每个专辑,因此这可能只是一个临时缓存问题。 If not, then a quick (but unlikely) guess is that Facebook is not distinguishing between those two pages because the only difference is the query string. 如果没有,那么快速(但不太可能)的猜测是Facebook没有区分这两个页面,因为唯一的区别是查询字符串。 Can you make the URLs more unique by using mod_rewrite (eg /album/the-pink-slip). 您可以使用mod_rewrite(例如/ album / the-pink-slip)使URL更加独特。

Also, you only need to use the fbrefresh=CAN_BE_ANYTHING parameter when submitting the URL in the object debugger -- you don't need to put it in the og:url property on the album page. 此外,在对象调试器中提交URL时,您只需要使用fbrefresh = CAN_BE_ANYTHING参数 - 您无需将其放在相册页面的og:url属性中。

You're not URL encoding the target URL when you post the request to Facebook's APIs. 当您将请求发布到Facebook的API时,您不是对目标URL进行URL编码。 Anything after the 2nd ? 第二次之后还有? is being ignored. 被忽略了。 You should instead do: 你应该这样做:

var album_url = "http://www.skibsthekid.com/parse.php?album=" + album;
FB.api('/me/skibsthekid:listen_to?album='+encodeURIComponent(album_url), 'post',...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM