I was thinking about how to retrieve photos from Facebook photo gallery’s and came across a number of solutions. Most of the solutions were for blog or CMS and furthermore required caching your credentials in a database along with a few other hoops in order to access your albums and display them on a third party site. I thought this was a bit odd as if you want to share photos on your blog or site you should be able to just make the album public and use Facebooks API to connect since they are going to be public at that point. After poking around this ended up being much easier than expected and it works with Facebook Fan Pages which is where I think this would be most useful.
- You need to create a Facebook application account which will provide you with your appId and secret.
- Next you need to get the PHP SDK from GitHub. All you need is the facebook.php page but feel free to grab the ZIP and explore. There is an example to experiment with.
- Lastly you can use the code provided on Google Code as a basic start to implementing a photo gallery on your site.
The code displays thumbnails, source images along with name’s (caption’s) below each image that have them and finally the source which you can use to derive other goodies that you might want to use in you gallery. Some examples are different size thumbnails, id, comments, etc.
*Note that the script does not parse double quotes in photo captions well at this point.
If you notice any issues, room for improvement or features feel free to leave a comment or post an issue over at the Google Code page.
doesn’t it violate any law/s? i would like to try this but I’m not sure if it’s really legal
Please refer to https://developers.facebook.com/policy/ This script parses a public albums. There are a number of scripts that can display private photos by storing credentials which may violate TOS but this does not store end user data except what a traditional web-server would. If you find otherwise please let me know.
would it be OK if I’ll give your link to Facebook team? I’m not really good in English and can’t understand most of their policies… I would like them to be the one to evaluate if this steps are legal or not…
i wasn’t able to thoroughly understand your post until now… i’m sorry for being a disturbance… next time i’ll understand it first before leaving a comment… as i thought, this isn’t done without permission from them, right?
The Facebook API http://developers.facebook.com/docs/guides/canvas/ is designed to facilitate data sharing. The code demonstrated in this blog post is for accessing public photos and information on Facebook, it is not intended to access private information though there are a number of third party applications that do this: http://vonlind.com/2010/01/embed-facebook-fan-page-photo-albums-in-wordpress/ or http://thinkdiff.net/facebook/open-source-facebook-photo-gallery/ or http://www.aaronharp.com/dev/wp-fotobook/
Hey there
Wow a great post, very useful.
Thanks!
So, is it legal to use user’s public photos directly from facebook’s cdn? I am just wondering in terms of a) is it TOS compliant to publicly show user’s photos on 3rd party site even if you have their permission and b) won’t facebook frown upon you using up their bandwidth?
@Jon, I cannot provide legal advice but feel free to view Facebook’s TOS: http://www.facebook.com/terms.php and http://developers.facebook.com/policy/
Specifically:
“For content that is covered by intellectual property rights, like photos and videos (IP content), you specifically give us the following permission, subject to your privacy and application settings: you grant us a non-exclusive, transferable, sub-licensable, royalty-free, worldwide license to use any IP content that you post on or in connection with Facebook (IP License). This IP License ends when you delete your IP content or your account unless your content has been shared with others, and they have not deleted it.”
and:
“When you publish content or information using the Public setting, it means that you are allowing everyone, including people off of Facebook, to access and use that information, and to associate it with you (i.e., your name and profile picture).”
This script leverages the Graph API.
Thanks for reply @Stephen. Great article.