Using sample SAD plugins

This distribution comes with three sample plugins: Twitter searcher, Facebook collector and Basic SNS stats (located in sad-plugins folder). Each can be run either by Using SAD Control panel or with a SAD Service API.

Twitter searcher (twitter-searcher)

This plugin retrieves up to 100 posts (argument: num_posts) from Twitter using Social Integrator library. Supported search terms (argument: search_terms) are:

_images/twitter_operators.png

It uses credentials located in sad-plugins/twitter-searcher/src/main/resources/oauth-twitter.properties.

For example, to search for “cute OR adorable” once using SAD Control panel, paste the following into Request template and click Send request to run Plugin:

{
  "pluginName": "twitter-searcher",
  "arguments": [
    {
      "search_terms": "cute OR adorable"
    },
    {
      "num_posts": "99"
    }
  ],
  "inputs": [],
  "outputs": [
    {
      "type": "twitter-static-search-raw"
    }
  ],
  "schedule": {
    "times": 1,
    "withIntervalInMilliseconds": 20000
  }
}

Use Job list at the bottom of the Control panel to monitor the progress of the plugin execution and once it’s finished, use links under the plugin name to view:

raw data - collected tweets as JSON:

{
  "response": {
  "series": {
  "0": {
  "jsonData": {
  "contributors": null,
  "text": "@Jamieboo8 hahahah you're so cute",
  ...
  },
  "num": 98,
  "jobstatus": "finished"
  }
}

visualised data - HTML/CSS/JS rendering of raw data:

_images/twitter_searcher_visualisation.png

job details - JSON containing job’s metadata:

{
   "result":"ok",
   "response":{
      "job":{
         "ID":1,
         "PluginName":"twitter-searcher",
         "Name":"Job for plugin twitter-searcher",
         "Description":"Job created by Scheduling service",
         "Arguments":[
            {
               "search_terms":"cute OR adorable"
            },
            {
               "num_posts":"99"
            }
         ],
         "Inputs":[
         ],
         "Outputs":[
            {
               "type":"twitter-static-search-raw"
            }
         ],
         "Schedule":{
            "times":1,
            "withIntervalInMilliseconds":20000
         },
         "Status":"finished",
         "WhenCreated_as_string":"2013-07-18 16:09:57",
         "WhenCreated_in_msec":1374160197491,
         "WhenLastrun_as_string":"2013-07-18 16:10:00",
         "WhenLastrun_in_msec":1374160200247,
         "Executions_num":1,
         "status_url":"http://localhost:8081/SAD/service/jobs/1",
         "data_url":"http://localhost:8081/SAD/service/jobs/1/data",
         "visualised_data_url":"http://localhost:8081/SAD/visualise/twitter-searcher/data.html?jobid=1&num_results=20"
      }
   }
}

Facebook collector (facebook-collector)

Uses Social Integrator library to collect max_posts recent posts from one or more Facebook pages (in case of multiple pages, max_posts recent posts from each page). Page names in page_name argument can be separated by commas or an individual page_name argument can be added for each Facebook page.

It uses credentials located in sad-plugins/facebook-collector/src/main/resources/oauth-facebook.properties.

For example, to collect recent 123 posts from each of “congressschladming”, “cocacola”, “Schladming2013” Facebook pages once using SAD Control panel, paste the following into Request template and click Send request to run Plugin:

{
  "pluginName": "facebook-collector",
  "arguments": [
    {
      "page_name": "congressschladming, cocacola"
    },
    {
      "page_name": "Schladming2013"
    },
    {
      "max_posts": "123"
    }
  ],
  "inputs": [],
  "outputs": [
    {
      "type": "facebook-posts-raw"
    }
  ],
  "schedule": {
    "times": 1,
    "withIntervalInMilliseconds": 20000
  }
}

Use Job list at the bottom of the Control panel to monitor the progress of the plugin execution and once it’s finished, use links under the plugin name to view:

visualised data - HTML/CSS/JS rendering of raw Facebook data:

_images/facebook_collector_visualisation.png

Hot tweets (hot-tweets) - only available in deployment release

Uses data collected by Twitter plugin to create a list of most influential tweets. It requires hours_back argument to know how far in the past to go back for input tweets and a location of data folder data_folder_path which is required by analysis algorythm:

{
 "pluginName": "hot-tweets",
 "arguments": [
   {
     "hours_back": "1"
   },
   {
     "data_folder_path": "./data"
   }
 ],
 "inputs": [
   {
     "plugin_name": "twitter-searcher"
   }
 ],
 "outputs": [
   {
     "type": "twitter-hot-tweets"
   },
   {
     "type": "twitter-static-search-raw"
   }
 ],
 "schedule": {
   "times": 1,
   "withIntervalInMilliseconds": 20000
 }
}

A feed of 5 latest hot tweets can be accessed at:

<SAD basepath>/service/executions/hot-tweets/twitter-hot-tweets

Basic stats for Twitter/Facebook collected data (basic-sns-stats)

Basic-sns-stats plugin can fetch num_posts social network posts collected by Twitter and Facebook plugins (described above) and extract basic stats from that data. It also provides examples of direct database access including extraction of media links and descriptions.

For example, to analyse 54 posts from the output of each of two previous plugins once using SAD Control panel, paste the following into Request template and click Send request to run Plugin:

{
  "pluginName": "basic-sns-stats",
  "arguments": [
    {
      "num_posts": "54"
    }
  ],
  "inputs": [
    {
      "plugin_name": "twitter-searcher"
    },
    {
      "plugin_name": "facebook-collector"
    }
  ],
  "outputs": [
    {
      "type": "twitter-basic-stats"
    },
    {
      "type": "facebook-basic-stats"
    }
  ],
  "schedule": {
    "times": 1,
    "withIntervalInMilliseconds": 20000
  }
}

Use Job list at the bottom of the Control panel to monitor the progress of the plugin execution and once it’s finished, use links under the plugin name to view:

visualised data - HTML/CSS/JS rendering of raw basic stats data:

_images/basic_stats_visualisation.png

Extracted media links with descriptions can be requested with the following output type:

"outputs": [
  {
    "type": "media-links-with-descriptions"
  },

and visualised alongside other output types:

_images/media_links_visualised.png