Facebook Api v2.2 - get album's photos shares count

爷,独闯天下 提交于 2020-01-05 10:28:22

问题


I'm using the following Graph Api query in order to receive the likes and comments counts on all the photos in an Album inside my page:

https://graph.facebook.com/v2.2/album_id?fields=photos.limit(250){likes.limit(1),comments.limit(1),id,source},likes.limit(1)&access_token=my_access_token

I want to to also receive each one of these pictures shares count, but the share count is not connected to the photo end point, Its connected to the page_story_id.

So, in order to receive all the shares count i'm going to need to query each of those individually, which doesn't make sense when you have an album with 200 pictures (not to mention an album with 500 pictures).

FQL is deprecated after v2.1 so I can't use the FQL to get this (which will defiantly ease everything for me).

Isn't there an easier way to do so?

Update Thanks to @CBroe comments, this is my batch:

[
 {
   "method":"GET",
  "name":"get-photos",
  "relative_url":"951337131548012?fields=photos.limit(250){likes.limit(1),comments.limit(1),id,source,page_story_id},likes.limit(1)"
  },
 {
  "method":"GET",
  "relative_url":"/?ids={result=get-photos:$.photos.data.*.page_story_id}"
 }
]

Now it does return all the photos post objects, but how can I query them all the specific field? like add ?fields=shares


回答1:


ok after struggling with this for few hours, and thank to @CBroe help I found the right batch request for my needs and it involves both batch and Graph API multiple requests.

[
 {
   "method":"GET",
  "name":"get-photos",
  "relative_url":"951337131548012?fields=photos.limit(250){likes.limit(1),comments.limit(1),id,source,page_story_id},likes.limit(1)"
  },
 {
  "method":"GET",
  "relative_url":"/?ids={result=get-photos:$.photos.data.*.page_story_id}&fields=shares"
 }
]

by adding &fields=shares i'm filtering the fields of inner results of the multi request.

Hope it helps someone :)



来源:https://stackoverflow.com/questions/28558311/facebook-api-v2-2-get-albums-photos-shares-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!