2017-02-20 27 views
1

我正在嘗試獲取音樂藝術家在其Facebook頁面上擁有的歌迷人數,但這不起作用。我已經梳理了FBAPI文檔以及SO,但仍然沒有。這裏是我的代碼:從Facebook的開放式圖表中獲取針對Facebook頁面的見解/ page_fans

func getHolychildInfo() { 
    //Make request 
    let newGraphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "/holychildmusic/insights/page_fans", parameters: ["period" : "lifetime", "show_description_from_api_doc" : "true", "fields": "read_insights"], httpMethod: "GET") 
    newGraphRequest.start(completionHandler: { (connection, result, error) in 
     if ((error) != nil) { 
      print("Holychild error getting insights: \(error.debugDescription)") 
     } else { 
      print("\nHolychild insights result:\n\n\(result)") 
     } 
    }) 
} 

這裏是我的結果:

data =  (
); 
paging =  { 
    next = "https://graph.facebook.com/v2.8/holychildmusic/insights/page_fans?access_token=EAAIB5k3aWEEBAHBD9lZC5AAzZAVV8K8CGBfqaxcrLdZA7oZB2Gdar8cQphXj4VciloZAnZBKp5ZA59BmGloSNz847nFqZCTVsYZCl9rrOk88OnfCnDwwADKnkOO5EUhGumEbW96riHplgfBLdnZAEYmB2Qz4ZAH1sWbuftmGKDqPft4l5QAHSZAimIyI6sOHaKWiurRK201Af6NQCXGliZBsZAUYosUHttkUbo4CQZD&fields=read_insights&format=json&include_headers=false&period=lifetime&sdk=ios&show_description_from_api_doc=true&since=1487457711&until=1487716911"; 
    previous = "https://graph.facebook.com/v2.8/holychildmusic/insights/page_fans?access_token=EAAIB5k3aWEEBAHBD9lZC5AAzZAVV8K8CGBfqaxcrLdZA7oZB2Gdar8cQphXj4VciloZAnZBKp5ZA59BmGloSNz847nFqZCTVsYZCl9rrOk88OnfCnDwwADKnkOO5EUhGumEbW96riHplgfBLdnZAEYmB2Qz4ZAH1sWbuftmGKDqPft4l5QAHSZAimIyI6sOHaKWiurRK201Af6NQCXGliZBsZAUYosUHttkUbo4CQZD&fields=read_insights&format=json&include_headers=false&period=lifetime&sdk=ios&show_description_from_api_doc=true&since=1486939311&until=1487198511"; 
}; 

正如你所看到的,沒有什麼迴應的「數據」部分。 「page_fans」見解度量標準應該返回一個數字 - 除其他外 - 但不會返回任何內容。

回答

1

除了這兩個公立(page_fans_country和page_storytellers_by_country)所有的見解的度量需要管理員訪問的頁面(admin用戶或頁面訪問令牌read_insights許可。)

但頁面對象的fan_count場是公開的,所以只是要求:

https://developers.facebook.com/tools/explorer/?method=GET&path=holychildmusic%3Ffields%3Dfan_count&version=v2.8

+0

謝謝@CBroe - 做到了!你知道我在哪裏可以找到FBAPI的其他公共頁面字段......在文檔中找不到它們。 –

+1

https://developers.facebook.com/docs/graph-api/reference/ – CBroe