This Forum has been archived there is no more new posts or threads ... use this link to report any abusive content
==> Report abusive content in this page <==
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Facebook Comment Api, mysql, php?
05-13-2014, 12:55 AM
Post: #1
Facebook Comment Api, mysql, php?
I have a image based website that I want to integrate with facebooks comment api (the site is database driven). People can click on a thumbnail and are brought to a larger version of that image on another page. I would like for people to be able to comment on the specific images they click on. The problem is all my unique images are linked to the same view.php page, just different parameters are passed to bring up that specific image. So my question is how do I apply a unique comment box for every image, even though the images are all displayed from the same view.php page. Do I paste the fb api code in a mysql column and cross over the parameter? Or is there another way? I've never worked with facebook api so I'm new to this.

Ads

Find all posts by this user
Quote this message in a reply
05-13-2014, 01:08 AM
Post: #2
 
This simple php function will print out the full url path when used, making it unique when you visit images on the same page as long as they have different parameters.

Example: view.php?id=id-goes-here

• Place the php function at the top of the page in php tags.

function fb_comments() {
print 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}

• Place the code below right after the opening <body> tag.

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

• Place the code below where you want the comments section to show, you can edit the data-num-posts and data-width attributes to your liking.

<div class="fb-comments" data-href="<?php fb_comments(); ?>" data-num-posts="5" data-width="500"></div>

and sorry but yahoo removes all format and makes it hard to read.

EDIT:
• go to https://developers.facebook.com/docs/ref.../comments/
• click "Get Code"
• get the JavaScript SDK from there (yahoo edited the one above and won't work)

Ads

Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)