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.

Sunday, 27 July 2014

Week 10 - Fine Tuning Part 2

Ten week's have passed since the coding period began for gsoc 2014,and I spent the last week fine tuning the code which I had written.

Fixes/Improvements:
  • Validation for nodes in fluid,It wont crash if the target nodes do not exist.
  • Logger now saves the log in the Data/Logs folder of the installation.
  • Work in progress to try and integrate blogger api.
Issues:
  • Blogger Api which i'm using is not namespaced,hence using that is quite tricky.

Sunday, 20 July 2014

Week 9 - Fine Tuning part1

By the end of last week I was done implementing all the features I set out to implement in my GSOC proposal.So I have put the project on review(link).
  This week I received a suggestion from Simon Schaufelberger to implement a social image feature so that instead of choosing random images in a page while posting,the user can choose which image he wants to be displayed with Faceebook and Twitter,and that will have a separate field in the inspector with image upload.

This Feature was implemented and a few more issues were solved regarding Twitter image sharing.

Saturday, 12 July 2014

Week 8 : PreView


Let's recap what I have been doing with this small video.Thanks to this project I'm getting to learn a lot of new technologies every week.This week since I indulged in creating a preview for Facebook and Twitter I got my hands dirty with TypoScript and Fluid for the First time.


Progress:
  • Facebook Preview System for Posting a page,which gives a sample layout with the Post Parameters chosen appropriately.

     
  • Twitter Preview System for Page Posting ,shows a simple template of what it will look like once posted on Twitter.



     
  • I have isolated any Twitter/Facebook CSS from this project as proprietary code would cause licensing issues.
  • Fixed a bug regarding caption limit to Facebook posting.  
Issues:
  • Unable to show image in preview.
  • There are some issues when previewing blank/incomplete pages
Next Week Goals:
  • Find and Fix any bugs relating to this project.and improve performance.
  • Make a tutorial explaining installation .
Catch this project on Github  or packagist.Drop a comment if you have any ideas on making this project better.

Monday, 7 July 2014

week 7 :Picture Perfect

Previously Image posting on Facebook used to work with an image link specified in the Config file.this week i set out to dynamically fetch the Image within the Node specified and grab the Web URL related to that link and pass it as a parameter for post.

Progress:
  • Used textFinder() which locates inner TextNodes and made changes to facilitate Image Nodes.
  • Image Nodes are analyzed and converted to resource to get the web URL.
  • Web URL is specified as the post paramter for the image and post is published.
  • some Code Clean up of existing redundant code and fixed a few Bugs of previous builds involving Headline Nodes.
Issues:
  • Lack of an actual server prevented me from testing image link because i have provided http/https links for Facebook/Twitter.
Next week Goals:
  • Implement a system for previewing the post on various channels.
Please post some suggestions if you have any idea on how to improve this project.
Follow Progress GitHub