如何获得更大版本的 Facebook 缩略图? [英] How to get larger version of Facebook's thumbnail images?

查看:18
本文介绍了如何获得更大版本的 Facebook 缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,Facebook API 返回这样的 URL,其中包含所有大小为 130x130 像素的帖子/相册图像:

Right now the Facebook API is returning a URL like this with all post/album images 130x130 pixels in size:

https://fbcdn-sphotos-ha.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/s130x130/10801504_570625556403546_6496651209845129904_n.jpg?oh=dcf8ab3752522532871d2aaab09b6e7e&oe=54E4402F&gda=1424027679_76464aeeaa5d232b8100d01476af4ec7

https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/s130x130/10801504_570625556403546_6496651209845129904_n.jpg?oh=dcf8ab3752522532871d2aaab09b6e7e&oe=54E4402F&gda=1424027679_76464aeeaa5d232b8100d01476af4ec7

如何根据该 URL 检索完整(或任何更大尺寸)的图像?

How do I retrieve a full (or any bigger size) image based on that URL?

例如这个:

https://fbcdn-sphotos-ha.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/p417x417/10801504_570625556403546_6496651209845129904_n.jpg?oh=cd2b5cb0d74f7306c098de9f56dc6e27&oe=54E1F4C1&gda=1423830001_e700bfac39039952bfee55b200c158bf

https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/p417x417/10801504_570625556403546_6496651209845129904_n.jpg?oh=cd2b5cb0d74f7306c098de9f56dc6e27&oe=54E1F4C1&gda=1423830001_e700bfac39039952bfee55b200c158bf

或者类似的东西?

从 URL 或/v/t1.0-9/中删除 s130x130 或将 _s 替换为 _n 或类似内容的所有其他建议都不再有效 - 我已经尝试了所有这些(尝试它们如果你不相信我,你自己).有没有办法做到这一点?不知道 Facebook 的人做了什么改变以禁用它...

All the other suggestions of removing s130x130 from the URL, or /v/t1.0-9/, or replacing _s with _n or anything like that aren't valid any more - I've tried them all (try them yourself if you don't believe me). Is there a way to make this happen? Not sure what Facebook guys have changed to disable that...

推荐答案

经过几个小时的搜索和梳理后,我找到了一个适合我的解决方案.就我而言,我从 {page-id}/posts 中提取帖子,但我很确定这也适用于您,因为我曾经使用与您提到的相同的方法获取更大的图像.

After a couple of hours searching and pulling my hair out, I found a solution that works for me. In my case I'm pulling posts from {page-id}/posts, but I'm pretty sure this will work for you too, seeing that I used to get larger images using the same approach as you mention.

这对我有用:

bigger_image="https://graph.facebook.com/" + picture_url_from_facebook.match(/_d+/)[0].slice(1) + "/picture?type=normal";

  • /_d+/匹配以下划线 (_) 开头的任何子字符串,后跟任何数字(d 匹配一个数字,d+ 一遍又一遍地匹配数字直到失败)
  • match(regex) 返回一个数组,其中包含可以找到与指定的正则表达式匹配的所有字符串
  • 我们获取第一个 ([0]) 元素,因为这将是一个下划线,后跟 Facebook 数据库中图片的 ID
  • 我们将字符串从索引 1 切片到末尾,因为下划线不是 ID 的一部分
  • 然后,我们使用图形 API 从 facebook 获取工作链接,无需任何额外调用(例如,您可以直接在 img 标签中使用它)
  • 您可以在@this fiddle我们为客户制作的这个页面

    感谢 Er Adhish 引领解决方案@https://stackoverflow.com/a/27075503/2908761

    Thanks to Er Adhish for leading the way to the solution @ https://stackoverflow.com/a/27075503/2908761

    这篇关于如何获得更大版本的 Facebook 缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆