Author : Viaprestige Web Agency
Package : Viasocial | Facebook class
Version : 1.0 Stable release
Graph API : 2.5
Date: 01/09/2015
Update : 12/10/2015
- The Source of Ideas
- The bases
- The Work Space
- Functionalities
- Upcoming
- Compatibility
- Requirements
- Components
- Installation
Viasocial is a simple PHP plugin, that makes the possibility to fetch comments from facebook's database, using the Graph API. Viasocial is created specially for WordPress, under Avada template.
Two weeks ago we decide to replace the default WordPress comments with facebook social plugin, so at this step everything is clear except that for example; we can't show the latest comments* in the sidebar, because that facebook social plugin is iframed, means that comments are outside website, and thats generate SEO problems. At this moment neither WordPress or WordPress's plugins can do that (no official methods).
So we decide to make something simple & clean, then we have chosen PHP, and we avoided using jQuery.
Notice : this plugin is totally different than Facebook WordPress plugin, and nothing is inspired form it at all.
- With the facebook's Graph API, we can get a json response from server to navigator, this response contains : comments count, shares count, likes count, comments, Authors, Date & Time, Author's ID and more...
- Viasocial gets these informations from navigator and includes it to website.
We choose WordPress as the best work space for our plugin, and we made it 100% compatible with Avada.
For other templates :
Use our official plugin Visaocial for WordPress.
- Get Comments count for posts in website.
- Get Shares & Likes count.
- Get Comments, Authors, Profile picture, Date & Time, Author's ID, Post's ID & more ...
- Customize yourself the template and avoid installing unnecessary plugins on your website.
- Include official Facebook plugins
- Compatible with Avada .po .
- Fully customizable, with additional CSS class.
- Viasocial is crystal clear, and simple to manipulate.
- Share the current page in facebook, using share().
- Show 1 comment from each post in Blog
Since Wordpress 4.2 & Avada 3.8.5
Viasocial startup release is simple & flexible & compatible with popular CMS :
| | | |
Depending on your customization.
And tested with success with popular plugins :
The powerfull cache engine : WP Rocket
Tested with success with latest WordPress core : v4.4
- PHP 5.4
- Curl
- Facebook Javascript SDK.
- Facebook comments plugin (JS).
- Facebook App ID & App Secret
- Wordpress & Avada updates.
Viasocial folder :
.Viasocial
+-- class
| --- facebook.class.php
+-- assets
| +-- css
| +-- js
| +-- img
Avada folder :
.Avada 3.8.6
|+--.single.php
|+--.single.php.bak
|+--.Readme.txt
|+--.includes
| | +-- .Viasocial
| | --- .class-fusion-widget-tabs.php
| | --- .class-fusion-widget-tabs.php.bak
Install Viasocial/facebook.class.php via composer :
$ composer require viaprestige/viasocial
Clone repo via Git
$ mkdir Viasocial
$ cd Viasocial
$ git clone https://github.com/Viaprestige/Viasocial
$ cd ..
$ start Viasocial
Include the facebook class in your project and make a call to it :
include_once('class/facebook.class.php');
Create instance and define {app-id} & {app-secret} :
$object = new Facebook('{app-id}','{app-secret}');
See more informations about {app-id} & {app-secret} HERE
Use count('{option}') function :
The object, is for example this article
Returns the object's ID :
$object->count('sourceId');
Returns the object's Type :
$object->count('sourceType');
Returns the object's URL :
$object->count('sourceUrl');
Returns comments count :
$object->count('commentCount');
Returns shares & likes count * :
$object->count('shareCount');
Notice : * shares and likes are both counted in the same time
Use function fetch('{option},{limit}') :
Returns full data : comment, author,picture, date & time, limited by 5
$object->fetch('all','5');
Returns full data with custom profile picture
$object->fetch('custom','5');
Returns authors IDs
$object->fetch('authorId','5');
Returns authors names
$object->fetch('author','5');
Returns user's profile picture
$object->fetch('picture','5');
Returns messages (comments)
$object->fetch('message','5');
Returns date & time of publishing
$object->fetch('datetime','5');
Returns date of publishing
$object->fetch('date','5');
Returns time of publishing
$object->fetch('time','5');
Use plugin('{option}') function :
Returns Facebook social plugins
$plugin_object = new Facebook('','');
$plugin_object->plugin('');
Use share() (Upcoming) function :
Returns the current URL to share on Facebook
$object->share();
See the share demo.
-
Copy all contents of . / includes folder into your website :
/wp-content/themes/Avada/includes
Using FTP client.
-
In your WordPress backoffice / Theme options / blog / deactivate comments to turn on Viasocial.
-
Put this custom css in your style :
.via-picture-box{ float: left; margin-right: 15px; height: 50px; width: 50px; } .via-datetime{ font-size: 12px; } .via-author { text-transform: uppercase; }
To run a demo, just put the main folder in your localhost WWW. then you have to edite facebook.class.php, by defining {url} in constructor :
// Debuging
// $this->settings['url'] = '{url}';
- How to create Facebook App and get App ID & App Secret ?
Read this article.