2011-09-07 127 views

回答

0
  • 等待。
  • 嘗試再次將該網址粘上去或告訴任何人爲你做(可能有imedate效果)
  • 等等。
0

試試這個:

$fbURL = 'https://developers.facebook.com/tools/debug/og/object?q='; 
$shareURL = '<YOUR URL>'; 
$excuteURL = $fbURL.urlencode($shareURL)."&format=json"; 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $excuteURL); 
//curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); 
$data = curl_exec($ch); 
curl_close($ch); 

請注意,您需要通過用戶代理,因爲這是由Facebook的服務器需要解析請求。

0

我有這個問題,但它是與特定的崗位,而不是整個網站。我在調試器中獲取緩存以在更新博客文章後顯示正確的圖片,但是當我將鏈接發佈爲狀態時,Facebook仍顯示舊圖片。我不想等了一天,看它是否最終會改變,所以我做了什麼網頁中列出:

https://webapps.stackexchange.com/questions/18468/adding-meta-tags-to-individual-blogger-posts

換句話說,這樣的事情:

<b:if cond='data:blog.url == "http://urlofyourpost.com"'> 
    <meta content='http://urlofyourimage.png' property='og:image'/> 
</b:if> 

基本上,你要將一個if語句硬編碼到你的頁面的HTML中,以便爲你改變那個帖子的任何內容而改變meta內容。這是一個混亂的解決方案,但它的工作原理。

0

以上方法並沒有爲我工作。但是,我已經使用JavaScript來清除緩存並在Facebook中獲取最新內容。

if(window.location.search.indexOf("facebook_refresh") >= 0) { 
    //Feature check browsers for support 
    if(document.addEventListener && window.XMLHttpRequest && document.querySelector) { 
     //DOM is ready 
     document.addEventListener("DOMContentLoaded", function() { 
      var httpRequest = new XMLHttpRequest(); 
      httpRequest.open("POST", "https://graph.facebook.com", true); 

      httpRequest.onreadystatechange = function() { 
       if (httpRequest.readyState == 4) { 
        console.log("httpRequest.responseText", httpRequest.responseText); 
       } 
      }; 

      //Default URL to send to Facebook 
      var url = window.location; 

      //og:url element 
      var og_url = document.querySelector("meta[property='og:url']"); 

      //Check if og:url element is present on page 
      if(og_url != null) { 
       //Get the content attribute value of og:url 
       var og_url_value = og_url.getAttribute("content"); 

       //If og:url content attribute isn't empty 
       if(og_url_value != "") { 
        url = og_url_value; 
       } else { 
        console.warn('<meta property="og:url" content=""> is empty. Falling back to window.location'); 
       }    
      } else { 
       console.warn('<meta property="og:url" content=""> is missing. Falling back to window.location'); 
      } 

      //Send AJAX 
      httpRequest.send("scrape=true&id=" + encodeURIComponent(url)); 
     }); 
    } else { 
     console.warn("Your browser doesn't support one of the following: document.addEventListener && window.XMLHttpRequest && document.querySelector"); 
    } 
}