从 Facebook 图表中检索照片 url

发布于 2024-10-16 23:37:56 字数 263 浏览 4 评论 0原文

我目前正在通过调用以下地址从 Facebook 获取新闻源: https://graph.facebook.com/me /home 。此处返回的对象有一个“from”键,其中包含名称、ID,有时还包含类别。我知道我可以抓取 ID 并将 /picture 放在末尾来获取图片的 url,但我不想进行额外的调用。有谁知道我是否可以传递一些标志来强制 from 对象也有一个个人资料图片?

I am currently fetching my news feed from facebook from a call to: https://graph.facebook.com/me/home . Objects returned here have a "from" key, that has Name, ID, and sometimes category. I know that I can grab the ID and put /picture on the end to get the url of the picture, but I don't want to have to make an extra call. Does anyone know if there is some flag I can pass in which forces the from object to also have a profile Pic in there too?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光①夏 2024-10-23 23:37:56

我认为这是不可能的,我猜测你可以使用fields参数来过滤返回的结果,但你不能扩展它......不是一个方法我知道。

但你真的不需要这个,你的问题并不是真正的问题,只要你有对象ID,你就可以认为你有“照片网址”,这实际上有很多好处:

  • 少一个要存储的字段在你的数据库中,
  • 你的数组中要处理的元素少了一个……
  • 来自 Facebook 的请求少了一个,并使 facebook json 更轻!

我的意思是:

echo "<img src='https://graph.facebook.com/$user_id/picture' alt='' />";

和:

echo "<img src='$user_photo' alt='' />";

另外,返回 json 中的照片 URL 并不意味着您不需要进行“额外调用”来实际获取/显示图像!

I don't think this is possible, I guess you can use the fields parameter to filter the returned results but you can't extend it...not a method that I know.

BUT you really don't need that, your issue isn't really a problem as long as you have the object ID you can consider that you have the "photo url", this actually has a lot of benefits:

  • One less field to store in your DB
  • One less element in your arrays to process..etc
  • One less request from Facebook AND making the facebook json lighter!

I mean what is the difference between:

echo "<img src='https://graph.facebook.com/$user_id/picture' alt='' />";

And:

echo "<img src='$user_photo' alt='' />";

Also, having the photo URL in the json returned doesn't mean that you don't need to make an "extra call" to actually get/display the image!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文