Thành viên:Nguyenthephuc/Note: Facebook open graph not clearing cache

Từ VLOS
Bước tới: chuyển hướng, tìm kiếm

Có hai giải pháp giải quyết vấn đề này, một thủ công và một script.

Thủ công[sửa]

Bước 1: Go to http://developers.facebook.com/tools/debug

Bước 2: Enter the URL following by fbrefresh=CAN_BE_ANYTHING

Examples:

  1. http://www.example.com?fbrefresh=CAN_BE_ANYTHING
  2. http://www.example.com?postid=1234&fbrefresh=CAN_BE_ANYTHING
  3. OR visit: http://developers.facebook.com/tools/debug/og/object?q=http://www.example.com/?p=3568&fbrefresh=89127348912

I was having the same issue last night, and I got this solution from some website.

Facebook saves your cache thumbnail. It won't refresh even if you delete the thumnail/image from your server. But Facebook allows you to refresh by using fbrefresh

I hope this helps.

Script jquery[sửa]

If you have many pages and don't want to refresh them manually - you can do it automatically.

Lets say you have user profile page with photo:


$url = 'http://'.$_SERVER['HTTP_HOST'].'/'.$user_profile;
$user_photo = 'http://'.$_SERVER['HTTP_HOST'].'/'.$user_photo;

<meta property="og:url" content="<?php echo $url; ?>"/>
<meta property="og:image" content="<?php echo $user_photo; ?>"

Just add this to your page:


$.post(
    'https://graph.facebook.com',
    {
        id: '<?php echo $url; ?>',
        scrape: true
    },
    function(response){
        console.log(response);
    }
);

Nguồn[sửa]