
Need
When developing web applications, it is often necessary to display posts of a user or a community from social networks. Social networks have their own widgets, which are connected via
iframe , with their appearance and style. What if we need to display posts simultaneously from several social networks with the possibility of changing the design of the display? If this is a pair of
twitter and
facebook , then there are several plugins that perform this task. Taking into account that the popularity of the social network Vkontakte in the CIS is very high, that is, the need for a plugin to support this network as well.
Social-feed
The jQuery Social-feed plugin allows you to simultaneously display posts from social networks
facebook ,
twitter and
vk . The display takes place through the sort by date.
')
Plug-in connection
First connect the styles and
javascript :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="js/function.js"></script>
If caching of posts in
cookies is required, you need to enable the following:
<script src="js/json2.js"></script> <script src="js/jquery.cookie.js"></script>
Next, create a container for posts:
<div class="social-feed-container"></div>
Initializing the
social-feed plugin:
$('.social-feed-container').socialfeed({ fb_username:'barack.obama', fb_limit:2, vk_username:1, vk_limit:2, vk_source:'all', tw_limit:2, tw_username:'jack', length:130, cookies:true, show_media:true });
- fb_username , tw_username , vk_username - user names in the corresponding social networks (for vk - user id );
- fb_limit , tw_limit , vk_limit - restriction on the number of displayed posts from the corresponding social networks;
- length - limiting the length of the post. If this value is exceeded, the post will be trimmed;
- cookies - caching of posts in cookies (in the current version it is supported only for twitter with the number of tweets less than 10).
Details
Styles for this plugin are taken from
twitter bootstrap , their effect applies only to the content of the post container.
Twitter has a limit of
150 requests per hour, which in this plugin is solved by caching the results in cookies (set cookies for this: true).
In order to get access to even the public
timeline of the facebook user through
opengraph , you need to get an
access-token . To do this,
register the facebook application and specify
app_id and
app_secret in the
php / settings.php file .
The plugin displays posts only from those social networks to which the corresponding usernames are specified during initialization (for
vk -
id ), for example, if you only want to show posts from
facebook and
vk - specify the
username only for them.
You can change the appearance of displayed posts in the template
php / template.phpSource
Github :
https://github.com/pavelk2/social-feedDemo :
http://pavelk2.imtqy.com/social-feed/I would be very happy to receive feedback on this plugin plugin. In the future, support for other social networks is expected.
UPDATE : the plugin is constantly evolving, stay tuned to
GitHub .
UPDATE : added support for content previews:
