简体   繁体   中英

Facebook Open Graph Cache Issue

I am creating an application that posts information to facebook when a user downloads a specific music album. 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. I have tried fbrefresh=CAN_BE_ANYTHING but nothing seems to be working. Does anyone have insight to this?

Album 1 Meta Information parse.php?album=The%2520Pink%2520Slip

Album 2 Meta Information parse.php?album=The%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

<?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. Can you make the URLs more unique by using mod_rewrite (eg /album/the-pink-slip).

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.

You're not URL encoding the target URL when you post the request to Facebook's APIs. 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',...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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