将 Facebook 照片 url 链接转换为照片的图形 api 对象 id
给定一个像这样的 Facebook 照片的链接:
http://www.facebook.com/photo.php?pid=123&id=456
如何获取该照片的内部 Facebook ID?从我在实验中看到的情况来看,链接中的“pid”不是“照片”表中 FQL 中的“pid”。我能想到的最好的方法是使用 userid (id=456) 读回所有用户的照片并查找匹配的链接 URL,但这既慢又笨拙。有没有更直接的方法?
编辑:这是我能想到的最好的方法,它有效,但如果用户有很多照片,它会拉回大量数据。它执行得相当快(1秒左右),所以没关系,但我仍然想知道是否有更直接的方法:
SELECT link,object_id,aid FROM photo WHERE aid in (SELECT aid FROM album WHERE owner=456);
然后在结果中搜索带有“pid=123”子字符串的匹配链接
事实证明我也需要相册的对象 ID 及其大小,因此我使用第一步中找到的匹配辅助工具进行第二次查询:
SELECT object_id,size FROM album WHERE aid='<aidFromStep1>' AND owner=456;
Given a link to a facebook photo like this:
http://www.facebook.com/photo.php?pid=123&id=456
how can I get the internal facebook id for the photo? The "pid" in the link is not the "pid" in FQL in the "photo" table from what I've seen in my experimentation. The best I can think of is to read back all the user's photos using the userid (id=456) and look for a matching link URL but that is slow and clumsy. Is there a more direct approach?
Edit: this is the best I've been able to come up with, it works but it pulls a lot of data back if the user has many photos. It executes reasonably fast (1 second or so) so it's OK but I'd still like to know if there is a more direct approach:
SELECT link,object_id,aid FROM photo WHERE aid in (SELECT aid FROM album WHERE owner=456);
then search the results for a matching link with the "pid=123" substring
It turns out I also need the object id for the album and its size, so then I do a second query with the matching aid found from the first step:
SELECT object_id,size FROM album WHERE aid='<aidFromStep1>' AND owner=456;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否是您想要的,但如果是 C# 调用,那么我已经通过以下代码完成了此操作
not sure if it is what you want but if C# is the call then i have done this through following code