从 Facebook 获取照片
Posted
技术标签:
【中文标题】从 Facebook 获取照片【英文标题】:Getting Photos From Facebook 【发布时间】:2015-07-22 13:10:28 【问题描述】:我使用这个函数来获取用户的照片:
func getFacebookPhotos()
var request = FBSDKGraphRequest(graphpath:"/me/photos?fields=from,tags,images", parameters: nil);
println("started request")
request.startWithCompletionHandler(self.handler)
func handler(connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!)
if error == nil
println(result)
if (result["paging"]! != nil)
var after = result["paging"]!["cursors"]!["after"]! as! String
var path = "/me/photos?fields=from,tags,images&after=" + after
var request = FBSDKGraphRequest(graphPath: path, parameters: nil);
println("started request")
request.startWithCompletionHandler(self.handler)
else
println(error)
问题是当我知道用户有更多照片时,我只得到 30 张照片。
如何获取所有照片?
【问题讨论】:
你在这个特定标签的 json 响应中得到了什么数据:- "paging" ? 下一页照片 developers.facebook.com/docs/graph-api/using-graph-api/… 【参考方案1】:需要传入一个limit
参数:
limit : This is the number of individual objects that are returned in each page. Note that this is an upper limit, if there are not enough remaining objects in the list of data, then less than this number will be returned. Some edges have an upper maximum on the limit value, for performance reasons. We will return the correct pagination links if that happens.
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#paging
【讨论】:
以上是关于从 Facebook 获取照片的主要内容,如果未能解决你的问题,请参考以下文章
从 Facebook 活动墙获取照片(包括非朋友的公开照片)
如何从 Facebook + Swift + Parse 获取封面照片