views:

1705

answers:

6

I'm developing a site for a client who already have the photos of his products on Facebook, and he wants the same albums to be replicated over his site. I was already using Facebook Connect, so I dropped a combination of photos.getAlbums and photos.get to dynamically make the galleries.

So far so good, but then I realized that if there's no user logged trough FBC, no session is created and the API becomes unusable, even for content that is publicly available. I obviously want to show the albums to everyone and not just the people who connect their accounts.

Is this how all functions in the Facebook API work? What's the best (easier to implement) workaround for this situation?

A: 

You are correct: you will be unable to use the API functions without having a user authenticated with Facebook.

You should copy/download all the photos to the site rather than pulling them from Facebook. Is there a particular reason you want to pull from Facebook, other than the fact that the photos are already there? Generally, you only use the API if you are actually integrating some functionality. Pulling from FB instead of having them on the site itself is a hugely inefficient way of serving the photos.

Dustin Fineout
Thanks for the answer, I guess I thought it would be easier if the client didn't have to upload the same content all over again, and I didn't have to create another backend module.
fandelost
A: 

That doesn't make sense to me - I have a (relatively simple) app that renders in facebook even if the user has never logged into facebook before (in which case it displays demo data).

When using the facebook PHP library, I just do this:

$facebook = new Facebook($api_key, $secret);

No session id required - but, obviously, api functions that depend on information about the user aren't going to work.

You can also look into an "infinite session" for your app - you could create an infinite session key for yourself and use that session to access the API.

Mike Heinz
Thanks, I can obviously render my app (in this case is just backend code) without a user session, but I can't use any of the API functions that would let me pull content from the albums.The "infinite session" idea sounded good, but it's partially deprecated: http://wiki.developers.facebook.com/index.php/New_Design_Platform_Changes#Changes_to_Session_Keys
fandelost
A: 

Hi fandelost,

what you did for your client and using photos.getAlbums and photos.get, is what I want to create for my client.

I am 1-day old learning Facebook connect as of this post and will appreciate your guidance on how to use JS API to show my client's FB photos in his site.

simonth
Sorry for the late response, I've answered my own question. Hopefully it can put you on the right direction, but I don't have much experience with the FB JS API since I used PHP to communicate with Facebook.
fandelost
No worries. I managed to solve my JS issue and now I am trying out the PHP method to get the albums. Like you I am facing issue with the session. Appreciate if you could share your code how you get the offline access and photo albums from facebook.
simonth
+3  A: 

For the record, I managed to solve this situation by developing a small backend that requires the client to login to Facebook once and give offline_access extended permission to the FB app, so I can save his session key and use it to authenticate the Facebook API client every time I need to use FQL to get non-public content.

One could obviously add some caching in the middle to avoid unnecessary requests to Facebook, but it's been working fine for months now without hitting any limits that I know of.

fandelost
Great answer- this seems like the most up to date way to do this. Out of curiousity - how did you authenticate the user? I'm currently using the JS SDK on the front end, however for my App (CMS) I want to publish posts to a facebook page when an editor publishes a post to their website. (Then store PostId for likes/comments/etc) Ideally, I would store the username/pw for a fb page admin and use graph api to auth invisibly. Any examples of this? Thanks!
Jason
+1  A: 

As of September 2010, this answer is no longer correct. You can now authenticate just as an application, with no associated user. See http://developers.facebook.com/docs/authentication/ for details. Or you can run this example code to get an access token:

curl -F grant_type=client_credentials \
 -F client_id=your_app_id \
 -F client_secret=your_app_secret \
 https://graph.facebook.com/oauth/access_token
lacker
A: 

Hi Guys,

I have a Client who Wanze to Display Pictures from an Album filtered by vertaub criteria on a Tab App.

How can i achieve this without an Access Token? Is it even possible?

Tnx

John Doeherty