有效地从第三方获取用户的照片
假设您有一个应用程序,您的用户将通过 Picasa 和 Facebook 进行身份验证,以便您获取他们发布的所有照片。为了简单地获取用户的所有照片,FB 和 Picasa 都需要相同的方法:
- 获取用户的相册列表
- 获取每个相册的图片列表
因此,对于采用这种方法的任何给定提供商,您需要制作 N + 1 个(N 是专辑数量)向第 3 方发出的请求。如果您同时执行几个这样的操作,那么速度似乎会变慢,这是可以避免的。
这种方法似乎有一些替代方案:
Facebook:
- 获取与用户相关的所有照片
- 解析这些照片以查找用户实际发布的
照片 这还将为您提供标记有您的用户的其他用户的照片,因此它可能最终会出现由于数据量巨大以及涉及的分页请求数量,其性能比原始方法更差。
Picasa:
这里有一个潜在的解决方法: 按人物获取 Picasa 中的所有照片
这可能会可以工作,但看起来很老套,即满足允许范围但仍然可以保证大于用户照片数量的非常高的值是多少。
我知道无论我走哪条路线,这都不会快,但是有人对我应该在这里做什么有建议吗?也总有可能我对它的看法完全错误。
Let's say you have an app where your user will authenticate with Picasa and Facebook in order for you to get all of the photos they have posted. To simply get all of a user's photos, both FB and Picasa require the same approach:
- Get a list of albums for the user
- Get a list of pictures for each album
So for any given provider with this approach, you are required to make N + 1 (N being number of albums) requests to the 3rd party. If you are doing a couple of these operations at once this seems like it would get preventably slow.
There seem to be a few alternatives to this approach:
Facebook:
- Get all photos related to user
- Parse these to find which were actually posted by the user
This will also give you other users' photos tagged with your user, so it may potentially end up performing worse than the original method due to sheer size of data as well as the number of request for paging involved.
Picasa:
There's a potential workaround here:
Get all photos from Picasa by person
That would probably work but seems hacky, i.e. what is a very high value that satisfies the allowable range but can still be guaranteed to be larger than the number of photos for the user.
I know this is not going to be fast no matter which route I go, but does anyone have suggestions on what I should do here? There's also always the possibility that I'm looking at it completely wrong too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议你使用FQL->
http://developers.facebook.com/docs/reference/fql/photo/
和
http://developers.facebook.com/docs/reference/fql/photo_tag/
它允许你进行一个大的查询,然后 facebook 在其端处理它,你可以对其进行调整,以便它返回给你一个用户被标记的图片列表。
抱歉,我无法帮助使用 Picasa,因为我从未使用过它。
I suggest you use FQL->
http://developers.facebook.com/docs/reference/fql/photo/
and
http://developers.facebook.com/docs/reference/fql/photo_tag/
It allows you to make one big query and facebook process it on their end, you can tweak it so it returns to you a list of pictures where user is tagged in for example.
I'm sorry I can't help with Picasa though, I never worked with it.