Saturday 16 August 2014

TYPO3 Neos:Multi Channel Publishing (Facebook)

In this Blog post I will try to explain and demonstrate the whole process of publishing content of your Neos website on other channels.This will cover basic usage as well as extending it.

Installation:

  • This Package is available on Packagist and Github Download manually or do composer install.
  • Include the Root.ts2 file of the Package in the Root.ts2 file of the Site.

Facebook:

Suppose you/your client has a facebook page and is tired posting the same content on his facebook page,what this basically does is it takes the data from your neos website and posts it on your clients facebook page and provides a link to the website.
Facebook is secure and works on the concept of access tokens,since I'm using a signal slot setup an Oauth popup would not be feasible and posting to a page would be impossible,therefore it is needed to specify the access token in the configuration file.this is a one time thing and may take 5 minutes.
  • Get a facebook Developer account first here
  • Create an app make sure the account is the page admin access.
                             
  • Click Get Access token and make sure you check the manage pages and publish access permissions.
                         
  • The access token which you get is valid only for 60 minutes hence it is required to extend it by visiting this link Convert this access token into a long lived one by https://graph.facebook.com/oauth/access_token?client_id=<your FB App ID>&client_secret= < your FB App secret> &grant_type=fb_exchange_token&fb_exchange_token=< your short-lived access token>
  • Your enter your appid and client secret from your app settings page and enter the access token which you got earlier in the link to get a long lived access token.
  •  Make a Graph API call to see your accounts using the new long-lived access token: https://graph.facebook.com/me/accounts?access_token=< your long-lived access token>

  • This displays all pages managed by you.Note down your pageid and access token for the page .Now you have an access token which is valid forever.
  • For any errors during the process you can debug your access token Debug token.
  • Go to your Configuration.yaml file in the Package and enter the above details.
  • appid and secret are available in you developer account page,user will be the id of your page which you got earlier
  • link will be the link to your server/website
  • caption/name/desc/image are any defaults you want to assign to your facebook post.Leave them blank preferably
  • token will contain your access token.
Congratulations you have successfully set up SocialConnect for facebook.

Let's try it out.
Currently Headline,Text and Document/Page Nodes are supported.

  • Enable Social Connect for a Headline Node and publish.
  • Try it out for other Nodes too!
Extending Social Connect:
  • Sometimes the client has custom NodeTypes which require SocialConnect
  • SocialConnect is built in such a way that it's easy to extend and add/customize NodeTypes
  • Basically the package consists of Helpers,Factories and Overrides.Helpers do all the communicating with the API,Factories make sure the right nodes are fetched and the Overrides define the content of the post.
  • In most cases it is taken care of,if the NodeType is a subclass of an existing one,for example RobertLemke's Blog Plugin work's fine because it inherits the Document type.
  • If you want a new NodeType to behave just like an existing one.you can change the FacebookFactory file to do so.

  •  To customize a way how an Override works,extend the base class FacebookOverride.php make sure all methods are overriden .Make the changes in the Factory file as above.
Social Connect also supports Twitter and Blogger.Please let me know if something is to be done to improve the Project and Request for new NodeType/Social Network Support.


No comments:

Post a Comment