2011-09-07 155 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"); 
    } 
}