Tuesday, October 8, 2013

Social Connected's SynchronizeData Task

This came up while I was putting together demos for my talk. I wanted to click a Like button, and see if I could get it to trigger a change in personalized content, without having to log back in. This might be helpful for keeping profile information current on browsers such as Chrome that keep you logged on forever.


To regularly update user information with the user profile data form the social network, you can use a Sitecore scheduled task. This allows you to synchronize the user information with the social network regardless of the user's activity on your website.
To enable this,  you need to set a time interval for the "SynchronizeData" method in the Sitecore.Social.config file:

<agent type="Sitecore.Social.Connector.ScheduledTaskPerformer" method="SynchronizeData"
interval="00:00:00">
</agent>

But I could not get this to actually update values!  I could see in the log that it was running, since it listed trying to update every Facebook account, but I could not see any of the values change.  A little digging with DotPeek turned up the reason: The method only calls the GetUserAccountBasicData, which returns an ID, email address, and full name, plus an Access token and secret. This is probably useful for ensuring the token is still valid, and will get a current name and email address, but will not see any other profile information.  If you want to code your own scheduled task to get a more complete information set, you should get started looking at the implementation of SynchronizeData, which contains the basic logic for finding and updating all social network accounts.

2 comments: