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.


Sunday 10 August 2014

Week 12

This week was less productive compared to the previous weeks because of my semester resuming ,but nevertheless I fixed a major issue which had in the closet since the first few weeks.the textFinder function which is employed in the override for facebook used to find child nodes based the on the given grammar,but if a page contained a page it would traverse that node too,since I was implementing this in FlowQuery there was no way known to me to ignore those pageNodes and successfully find all other child nodes,so I coupled the TYPO3 Content Repository along with FlowQuery ,I get an array of all child nodes satisfying the grammar(node type) and then use TYPO3CR to check if their parent page node is the page concerned.This was I was able to find the best matching nodes for that page.

Next week I wish to implement a multi-threading approach for all the api-calls to improve performance.

Saturday 2 August 2014

Week 11 - Blogception

This title is a homage to 2010's Hollywood blockbuster of
the name Inception,which dwells into the concept of dreams inside
dreams.Usually every weekend i log into blogger and post my updates about that week's work,this week I used the Blogger Posting feature of Social Connect which i just added to post directly from my Neos Website.
This week's progress:
  • Made enhancements to some more code.
  • Added blogger posting to social connect.
  • Providing a username/password combination in the Configuration file along with the name of the blog to post to blogger.
Issues faced:
  • The Blogger posting is still very basic and unstable.
Next Week Goals:
  •  Improve Blogger Posting support complex structures/nodes if possible
  • clean up some more old code.

Catch the progress on Github and comment here for any suggestions/changes.