简体   繁体   English

Facebook:为用户获取公开照片

[英]Facebook: Get Public Photos for User

I am trying to build a web app that pulls all public photos from any user's Facebook account given the profile URL and was wondering if this is possible. 我正在尝试构建一个网络应用程序,该应用程序会在给定配置文件URL的情况下从任何用户的Facebook帐户中提取所有公开照片,并且想知道是否有可能。 For example, on some accounts, I can go to a person's Facebook profile without being logged in and view a profile picture, some cover photos, etc. 例如,在某些帐户上,我无需登录即可进入一个人的Facebook个人资料,并查看个人资料图片,一些封面照片等。

I am writing this using React.js. 我正在使用React.js编写此代码。

If I were given 如果给我

this.props.urlOfFacebookUser

where the urlOfFacebookUser is facebook.com/urlOfFacebookUser 其中urlOfFacebookUserfacebook.com/urlOfFacebookUser

Could I somehow use this value to query their public photos? 我可以以某种方式使用此值查询他们的公开照片吗?

You could do this in two ways, either with a scraper or an API. 您可以通过两种方式执行此操作,或者使用刮板或API。

In order to accomplish it in the way you are describing you'll need to use a web scraper (like Nokogiri ). 为了按照您描述的方式完成此操作,您需要使用网络抓取工具(例如Nokogiri )。 You could set it up to scrape the specific element you are attempting to access. 您可以将其设置为抓取您要访问的特定元素。 To do this, open the developer console while on Facebook and figure out how to precisely target the image. 为此,请在Facebook上打开开发人员控制台,并弄清楚如何精确定位图像。 (The Nokogiri site I've provided has tutorials on this.) (我提供的Nokogiri网站上有关于此的教程。)

The other, and probably more legitimate, way of going about this is by connecting to the Facebook Graph API. 另一种可能更合法的方法是连接到Facebook Graph API。 The instructions on how to do this are here . 有关如何执行此操作的说明在此处

Getting the API set up might be daunting, but from my experience scrapers are often more trouble than they are worth. 设置API可能会令人生畏,但以我的经验来看,抓取工具通常比他们值得的麻烦更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM