简体   繁体   中英

Facebook “Like” a photo in a list of photos on single PHP page

What I'm trying to accomplish seems like it should be pretty simple...

I have a gallery of 10-20 photos in a grid, all on a single PHP page.

I want a Facebook "Like" button below each photo. When the "Like" is shared on the user's profile (if they choose), I want it to show the photo they liked, but link to the page with the gallery.

A wireframe image of what I'm trying to accomplish is here: http://i.stack.imgur.com/u3h0E.png

Right now, I'm simply using a simple Facebook Like Button, but I want to tie each Like Button to the respective photo, yet have it all tied back to this gallery page.

Any help or direction is appreciated! Would certainly prefer to stay away from setting up anything complicated with the Graph API, but if that's the only method, let me know!

One quick solution would be to have each photo in the gallery (and its respective like button) render within its own IFRAME. As far as the photo display and LIKE button are concerned, they live in a separate context (and URI). You could then redirect any requests to that URI that don't originate from an AJAX request (ie whenever someone tries to access the content that has been "Liked") to the gallery page. This has the added advantage that you can (as your app evolves) use AJAX calls to substitute out and load in new photos, in place of the old ones, with minimal effort (that's a tangent though).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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