Blame view

README.md 2.06 KB
410cbe3b3   James McMinn   First commit with...
1
2
3
4
5
6
7
  Go Twitter Tools
  =====================
  
  The Twitter Microblog Track runs a rather special Evaluation as a service
  model, which allows participants to connect to a server to perform queries
  using a thrift-based API. This package provides a set of Go bindings for
  performing queries to the service, in addition to a wrapper library which
6a0eec3b0   James McMinn   Fixed readme and ...
8
  simplifies its use.
410cbe3b3   James McMinn   First commit with...
9
10
11
12
  
  ## Requirements
  The library requires the thrift package from Apache, which can be installed
  using:
6a0eec3b0   James McMinn   Fixed readme and ...
13
14
15
16
17
18
19
20
      go get git.apache.org/thrift.git/lib/go/thrift
  
  ## Installing
  Go get can handle installation for you.
  
      go get git.apache.org/thrift.git/lib/go/thrift
  
  ## Usage
90da1f0d2   James McMinn   Readme change
21
  The library is modelled loosely on the official Microblog track client, which is written in Java. It’s very simple and implements 3 basic actions: 
cd5930678   James McMinn   Readme change
22
23
24
   1. Create a connection 
   2. Perform a query and return results
   3. Close the connection.
e5a6ef861   James McMinn   Readme change
25

90da1f0d2   James McMinn   Readme change
26
  All of these are demonstrated in the example below.
6a0eec3b0   James McMinn   Fixed readme and ...
27
28
29
30
31
32
33
34
  
      package main
  
      import (
          "fmt"
          "log"
          "mirgit.dcs.gla.ac.uk/JamesMcMinn/twitter-tools-go"
      )
e5a6ef861   James McMinn   Readme change
35
      
6a0eec3b0   James McMinn   Fixed readme and ...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
      func main() {
          // Create a new client using the settings in conf.json
          client, err := twittertools.NewClientFromConf("conf.json")
          if err != nil {
              log.Fatal(err)
          }
          defer client.Close()
  
          // query the server for "glasgow", retreive the top 50 results
          // -1 signifies that there is no maximum tweet ID
          results, err := client.Search("Glasgow", 50, -1)
          if err != nil {
              log.Fatal(err)
          }
  
          // Iterate over the results, printing text from each tweet
          for k, result := range results {
              fmt.Println(k, result.Text)
          }
      }
  
  The example uses a conf.json file (example below) to load the server details and your team details. If you’d rather hard-code the values, the `twittertools.NewClientFromDetails(host, port, group, token)` function allows you to create a new client and specify the details manually.
  
      {
        "Host":  "server.address.edu",
        "Port":  9091,
        "Group": "UrTeamName",
        "Token": "de4db33f"
      }