newscoop/facebook-newscoop-bundle

Usefull sevices for integration Newscoop and Facebook

Installs: 473

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 17

Forks: 8

Open Issues: 0

Type:newscoop-plugin

dev-master 2017-11-03 11:51 UTC

This package is auto-updated.

Last update: 2024-12-24 04:58:18 UTC


README

Features

  • Facebook caches shared URLs for better performance. This can cause problems when we want to change the title or description of a Newscoop article, because Facebook still has the older version. This plugin is designed to fix the problem by clearing the article cache on Facebook and updating Open Graph tags.
  • This plugin also provides an easy way to generate all required Open Graph tags with a simple template block.
  • Newscoop provides a way to schedule article publishing in advance, but before publishing the article you can't plan the announcement on Facebook, as Facebook won't fetch article metadata. This plugin exposes a special URL for the Facebook crawler so that you can plan posts with scheduled articles. This URL will redirect readers to the real articles when those scheduled articles are published.

Installation

Step 1:

In the Newscoop server console, run the command:

$ php application/console plugins:install "newscoop/facebook-newscoop-bundle" --env=prod

This plugin will be installed to the newscoop/plugins/Newscoop directory.

Step 2:

Go to an article edit page in Newscoop to see the Facebook Plugin on the right sidebar.

Also read more about Lifecycle Subscriber Managing.

Database table for the plugin

This plugin has only one entity: Facebook.php. After the plugin is installed, your Newscoop database will have a new table: plugin_facebook_informations.

This table keeps information from Facebook about an article, such as:

  • article - article ID
  • language - article's language ID
  • title - article title
  • description - article description
  • created_at - date when information was added
  • is_active - information status

Generating Open Graph tags using a Smarty plugin

In the Newscoop/FacebookNewscoopBundle/Resources/smartyPlugins directory you will find the file: block.facebook_meta_block.php

This file is a Facebook metadata block plugin. It generates the Facebook Meta information for a page. The Smarty plugin will be automatically autoloaded and available in your templates.

To test and display metadata generated by the Smarty plugin just put this block into _html-head.tpl:

{{ facebook_meta_block admins="123422,234223432,234234234,23423423" }}{{ /facebook_meta_block }}

The Smarty plugin will generate HTML code, for example:

//ex.
<meta property="og:title" content="Lionel Messi: the Argentinean who makes children dream all over the world" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http:/newscoop.dev/en/may2013/sports/80/Lionel-Messi-the-Argentinean-who-makes-children-dream-all-over-the-world.htm" />
<meta property="og:site_name" content="The New Custodian" />
<meta property="og:locale" content="en" />
<meta property="og:description" content="Malorum prompta maiestatis ius at, vim movet cotidieque ei. Erroribus torquatos vel et, pri nostro causae gubergren id. Per ut cetero laoreet recteque, cetero lucilius phaedrum his at" />
<meta property="article:section" content="Sports" />
<meta property="article:author" content="Amerigo Vespucci" />
<meta property="article:published_time" content="2013-05-02 08:17:08" />
<meta property="fb:app_id" content="499467366771848" />
<meta property="fb:admins" content="123422,234223432,234234234,23423423" />
<meta property="og:image" content="http://newscoop.dev/images/cms-image-000000124.jpg" />

You can read more about Open Graph tags in the Facebook developer docs.

Submitted and scheduled for publication articles on Facebook

This plugin provides a special treatment for articles which have not yet been published.

The URI has this format: /f/+{webcode}

For example: /f/+j6gd4 and can be found in the plugin's sidebar widget in the article editor.

Screen

By default only simple HTML structure with Open Graph meta tags will be rendered for the Facebook crawler. You can override this with the __fb_submited_article.tpl template file included in your template.

Example template output:

<!DOCTYPE html>
<html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>test article</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
        <meta name="description" content="">
        <meta name="keywords" content="" />
        <meta property="og:title" content="test article" />
        <meta property="og:type" content="article" />
        <meta property="og:url" content="http://newscoop.dev/en/2/2/130/" />
        <meta property="og:site_name" content="test publication" />
        <meta property="og:description" content="" />
        <meta property="article:section" content="police" />
        <meta property="og:image" content="http://newscoop.dev/images/cms-image-000000011.jpg" />
        <meta property="article:publisher" content="https://www.facebook.com/newscoop.dev" />
        <meta property="og:author" content="http://facebook.com/newscoop.dev" />
        <meta name="author" content="test publication" />
    </head>
</html>

Plugin in action:

When you enter the article edit screen in Newscoop, the plugin will check if there is already information about that article in the database. If not, it will connect to Facebook Graph API and download all necessary information. Next, that information will be inserted into the Newscoop database.

If connection to Facebook is a success, the status message on Screen 1 will show up.

Screen 1

Screen 1: General Plugin view.

To clear the article cache, just click the Clear article cache on Facebook button and a message will show up (look at Screen 2).

Screen 2

Screen 2: Connecting message after button click.

If for some reason connection to Facebook isn't possible, we will see an error message (look at Screen 3)

Screen 3

Screen 3: Connection to Facebook failed - status message.

License

This plugin is released under the GNU General Public License v3. You can read the complete license in the source.

About

The Facebook plugin for Newscoop is a Sourcefabric z.ú. initiative.