2011-02-07 136 views

回答

4

使用社交圖譜,您可以執行此操作,前提是該腳本具有您的Facebook頁面應用程序ID的訪問令牌,或者您的照片權限設置爲完全公開。

使用社交圖譜,您基本上可以通過類似Web服務的REST訪問照片。該Web服務調用將返回dataExample的JSON對象:

https://graph.facebook.com/cocacola/albums 

(相冊爲可口可樂的粉絲專頁)

因此,第一步將檢索使用類似上面的一個URL的相冊。 遍歷相冊並獲取所需專輯的對象ID。

{ 
     "id": "455377148305", 
     "from": { 
      "name": "Coca-Cola", 
      "category": "Company", 
      "id": "40796308305" 
     }, 
     "name": "Coca-Cola Fanmeile FIFA WM 2010", 
     "link": "http://www.facebook.com/album.php?aid=249745&id=40796308305", 
     "count": 20, 
     "type": "normal", 
     "created_time": "2010-10-22T15:53:36+0000", 
     "updated_time": "2010-10-22T15:55:23+0000", 
     "comments": {} 
}, 

只要將對象ID設置爲圖形URL的第一個參數,就可以訪問它。例如:

https://graph.facebook.com/40796308305 

從那裏,你應該能夠抓住實際的URL的圖像(根據權限設置)

{ 
    "id": "40796308305", 
    "name": "Coca-Cola", 
    "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs236.ash2/50516_40796308305_7651_s.jpg", 
    "link": "http://www.facebook.com/coca-cola", 
    "category": "Company", 
    "website": "http://www.coca-cola.com", 
    "username": "coca-cola", 
    "products": "Coca-Cola is the most popular and biggest-selling soft drink in history, as well as the best-known product in the world.\n\nCreated in Atlanta, Georgia, by Dr. John S. Pemberton, Coca-Cola was first offered as a fountain beverage by mixing Coca-Cola syrup with carbonated water. Coca-Cola was introduced in 1886, patented in 1887, registered as a trademark in 1893 and by 1895 it was being sold in every state and territory in the United States. In 1899, The Coca-Cola Company began franchised bottling operations in the United States.\n\nCoca-Cola might owe its origins to the United States, but its popularity has made it truly universal. Today, you can find Coca-Cola in virtually every part of the world.", 
    "likes": 22264613 
} 
+0

這是輝煌的,有沒有辦法我們的遊客可以在評論照片,然後評論將顯示在Facebook上呢? – steven 2011-02-09 21:38:33