Show DevBest Facebook Commenting Script [PHP]

Status
Not open for further replies.

Savallusion

#swipeproject
Jul 16, 2010
990
220
vqqre8.png



First off, a few things you might wonder.​


What is SFBs?SFBs is a simple facebook commenting system. You can soon easily integrate facebook comments to the site you want it on!

What's different from the Facebook Comment system you can find ?
Well, this is in PHP and have integrated the PHP into the script. It also saves your application ID, width, siteurl and more in your database. I'm going to develop on this later on aswell, to include more things to do with the systems!

now, let's get on with the showcase. You all might already know, but facebook has a smaller script that does the same purpose. The main reason for why i made this, is that i want to learn, and i were kinda bored.. I figured this might be a good idea though, as i have a blogging software that i'm going to integrate this script with. The script will include an installation file, which i am currently working on, and the chance of editing whatever you'd like whenever you'd like.

If you want the script to integrate towards your own blog software, that shouldn't become a huge problem. All you'd have to do is put all necessary codes in wherever you want it. For it to work with your blog posts, i can provide some help if needed. But now it's been too much writing and reading for you. Here's a picture!

rsvz7m.png

So far it's in a basic stage, and doesn't look too much of a big deal. However, this is easy to integrate with your own personal systems!

Here's the pre-release:

This must be put underneath your starting <body> tag for the best performance.
PHP:
<?php
include('config.php');
?>
<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/nb_NO/all.js#xfbml=1&appId=<?php echo $appid; ?>";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Put this in where you want the comments to be shown.
PHP:
<div class="fb-comments" data-href="<?php echo $sitelink; ?>" data-num-posts="2" data-width="<?php echo $width; ?>"></div>
Configuration file (config.php):
PHP:
<?php
/*---------------------------------*\
| Simple facebook commenting system |
| by Sindre-Emil G. Marthinussen    |
| *===============================* |
| http://sindreegmarth.com/         |
| *===============================* |
| This script is released under the |
| the public GNU license which can  |
| be found at http://www.gnu.org.   |
| *===============================* |
| Facebook Open Graph has been used |
| and included in this script.      |
\*---------------------------------*/
 
$dbhost = "localhost"; //localhost as default
$dbuser = "root"; //Default is root
$dbpass = "yourpw"; //your password
$dbname = "opengraph"; //The database you wish to connect towards
 
/*do not do anything to the content underneath*/
$connect = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$connect)
  {
    die("Couldn't connect to the database");
  }
mysql_select_db($dbname, $connect) or die("Database doesn't exist, please check your settings!");
 
$apps = mysql_query('SELECT * FROM apps');
while ($row = mysql_fetch_array($apps))
  {
   $appid = $row['appid'];
  }
 
$site = mysql_query('SELECT * FROM site');
while ($row = mysql_fetch_array($site))
  {
    $sitelink = $row['link'];
    $width = $row['width'];
  }
 
?>
Of course, we can't forget the database!

To insert your own appid, width and sitelink. You will have to go into the database and change those. I have for now, not made any systems to create this as i'm focusing on making the system easier to integrate!

Here's a temporary page to test it out:
PHP:
<?php
/*---------------------------------*\
| Simple facebook commenting system |
| by Sindre-Emil G. Marthinussen    |
| *===============================* |
| http://sindreegmarth.com/         |
| *===============================* |
| This script is released under the |
| the public GNU license which can  |
| be found at http://www.gnu.org.   |
| *===============================* |
| Facebook Open Graph has been used |
| and included in this script.      |
\*---------------------------------*/
?>
<html>
<head>
<title>Test page</title>
<style>
#box {
  background-color: #eee;
  border: 1px solid #ccc;
  width: 600px;
  margin:0 auto;
  padding: 4px;
}
</style>
 
</head>
<body>
<?php
include('config.php');
?>
<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/nb_NO/all.js#xfbml=1&appId=<?php echo $appid; ?>";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
 
<div id="box">
Hello world!<br />
<br />
 
<div class="fb-comments" data-href="<?php echo $sitelink; ?>" data-num-posts="2" data-width="<?php echo $width; ?>"></div>
</div>
</body>
</html>
Here's all the files in one .rar file for you..


Remember, i'm still working on it. So don't start on being harsh on the comments! :cool:
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Looks exactly the same to me besides that it is more 'dynamic' by adding a PHP variable to the script.
 

Savallusion

#swipeproject
Jul 16, 2010
990
220
Ik, but it's easier to integrate and edit the appid via your administration panel if you just add a few more functions. What i'm currentl focusing on is making it easier to integrate, aka. Making smaller functions to insert to your script. E.g {comments} to setup the comments properly. It's still just in it's basic stages, that's the reason why it's just a few changes to it.
 
Status
Not open for further replies.

Users who are viewing this thread

Top