0.0.4 • Published 9 years ago

errand-component-twitter v0.0.4

Weekly downloads
3
License
-
Repository
github
Last release
9 years ago

#errand-component-twitter

errand task for working with Twitter API

errand-component-twitter is an errand component that is used to work with twitter.

##Usage:

###Example of how to use errand-component-twitter in errand task list

{
  "tasks": [
    {
      "description": "task to get data for users twitterapi & twitter",
      "task": "errand-component-twitter",
      "parameters": {
        "method": "get",
        "path": "users/lookup",
        "params": {
        "screen_name":"twitterapi,twitter"
        },
        "result": {
          "description": "sub task to append to file test.log the value of status.created_at from the request",
          "task": "errand-component-file",
          "parameters": {
            "config": "default.json",
            "filename": "test.log",
            "data": "${result.id_str}",
            "method": "append"
          }
        }
      }
    }
  ]
}

###Example of how to use use errand-component-twitter to page Twitter search results

    {
      "description": "task to get search",
      "task": "errand-component-twitter",
      "parameters": {
        "config": "config/default.json",
        "method": "get",
        "path": "search/tweets",
        "page": true,
        "whilst": {"nMatched":0},
        "params": {
          "q":"nodejs",
          "count": 10,
          "result_type": "mixed"
        },
        "result": {
          "description": "task to append some search data to a mongodb collection",
          "task": "errand-component-mongodb",
          "parameters": {
            "config": "config/default.json",
            "method": "upsert",
            "database": "test",
            "collection": "test_nodejs",
            "find": "id_str",
            "data": "${result}"
          }
        }
      }
    }

Where:

  • description describes task
  • task is the name of task
  • parameters.config filename of config file
  • parameters.method http methods, options: get
  • parameters.path Twitter API endpoint
  • parameters.params (optional) parameters for the request
  • parameters.result (optional) task for result, refer to sub task description for values
  • parameters.page (optional) used to page down Twitter result, options: true or false
  • parameters.whilst (optional) use to continue paging page, options: object that matches stats returned for result
    • where result uses errand-component-mongodb then stats will have value to that matches following BulkWriteResult - nUpserted, nInserted, nModified, nMatched or nRemoved
  • parameters.result.parameters parameter values can be replaced:
    • with the result using object dot notation for specific values
    • ${result} is used to return the entire result object as a value

Refer to tests for more examples of use.

##Config

Add following details to your config file.

{
  "errand": {
    "errand-component-twitter": {
      "consumer_key": "...",
      "consumer_secret": "...",
      "access_token": "...",
      "access_token_secret": "..."
    }
  }
}

##Notes:

  • Ensure that any sub tasks are started.
  • Component does not rate limit requests.