如何使用 Facebook graph API 检索上传到粉丝专页墙上的粉丝照片?
我正在使用 PHP 和 Facebook 图形 API 创建一个外部照片库。它从我们的 Facebook 粉丝页面上的相册中提取缩略图和大图像。
一切都很完美,除了我只能检索管理员发布到我们页面的照片。 (graph.facebook.com/myalbumid/photos) 有没有办法使用 graph api 加载粉丝公开上传的照片?
我想从“照片来自”相册中检索图片,但尝试获取图形查询的 ID 与其他相册不同......它看起来像这样:http://www.facebook.com/ media/set/?set=o.116860675007039
另请注意:我接近检索此数据的唯一方法是使用“feed”选项..即:graph.facebook.com/ pageid/feed
编辑: 这是我所能得到的——它有效,但存在下面所述的某些问题。也许有人可以对此进行扩展,或者提供更好的解决方案。 (使用 FB PHP SDK)
<?php
require_once ('config.php');
// get all photos for album
$photos = $facebook->api("/YourID/tagged");
$maxitem =10;
$count = 0;
foreach($photos['data'] as $photo) {
if ($photo['type'] == "photo"):
echo "<img src='{$photo['picture']}' />", "<br />";
endif;
$count+= 1;
if ($count >= "$maxitem") break;
}
?>
与此有关的问题:
1)事实上,我不知道用于图形查询特定“类型”标签的方法,我必须运行条件语句来显示照片。
2)您不能有效地使用“?limit=#”,因为正如我所说,“标记”查询包含所有类型(照片、视频和状态)。因此,如果您要访问照片库并希望避免使用 ?limit 运行整个查询,您将丢失图像。
3)“标记”查询中显示的唯一内容来自非页面管理员的人员。这不是世界末日,但我不明白为什么 Facebook 不允许你自己显示在这些数据中,只要你“以你自己的身份”而不是以页面的形式发布它。
I am creating an external photo gallery using PHP and the Facebook graph API. It pulls thumbnails as well as the large image from albums on our Facebook Fan Page.
Everything works perfect, except I'm only able to retrieve photos that an ADMIN posts to our page. (graph.facebook.com/myalbumid/photos) Is there a way to use graph api to load publicy uploaded photos from fans?
I want to retrieve the pictures from the "Photos from" album, but trying to get the ID for the graph query is not like other albums... it looks like this: http://www.facebook.com/media/set/?set=o.116860675007039
Another note: The only way i've come close to retreiving this data is by using the "feed" option.. ie: graph.facebook.com/pageid/feed
EDIT:
This is about as far as I could get- it works, but has certain issues stated below. Maybe someone could expand on this, or provide a better solution. (Using FB PHP SDK)
<?php
require_once ('config.php');
// get all photos for album
$photos = $facebook->api("/YourID/tagged");
$maxitem =10;
$count = 0;
foreach($photos['data'] as $photo) {
if ($photo['type'] == "photo"):
echo "<img src='{$photo['picture']}' />", "<br />";
endif;
$count+= 1;
if ($count >= "$maxitem") break;
}
?>
Issues with this:
1) The fact that I don't know a method for graph querying specific "types" of Tags, I had to run a conditional statement to display photos.
2) You cannot effectively use the "?limit=#" with this, because as I said the "tagged" query contains all types (photo, video, and status). So if you are going for a photo gallery and wish to avoid running an entire query by using ?limit, you will lose images.
3) The only content that shows up in the "tagged" query is from people that are not Admins of the page. This isn't the end of the world, but I don't understand why Facebook wouldn't allow yourself to be shown in this data as long as you posted it "as yourself" and not as the page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要检索所有相册,然后获取所有照片。这可以通过使用 FQL 轻松完成:
编辑:
此外,您还需要查询流表以获取墙帖,然后检查是否有附件以及附件的类型:
结果:
You need to retrieve all the albums and then get all the photos. This can be easily done by using FQL:
EDIT:
Also you need to query the stream table to get the wall posts then check if you have attachments and the type of the attachment:
Result:
尝试这个 FQL:
filter_key="others" - 这将过滤来自其他人的帖子,但不会过滤来自管理员的帖子
type="" - 这会过滤掉评论,所以会给你留下照片(也许是视频和其他强悍的东西,但删除文本帖子会大大减少结果)
try this FQL:
filter_key="others" - this will filter posts from everyone else, but not from Admin
type="" - this will filter out comments, so will leave you with photos (maybe videos and other strenge things, but removing text posts will reduce result massively)