Sample code for github.com/kurrik/twittergo
Go JavaScript
Switch branches/tags
Nothing to show
Latest commit 6a18a9f Aug 22, 2017 @kurrik Add note about line endings
Permalink
Failed to load latest commit information.
custom_struct Add an example showing how to use custom structs Feb 21, 2016
emoji Update the emoji sample to print all the emoji tweets. Jul 24, 2014
favorites Clean up comments for favorites example Nov 5, 2016
home_timeline_app_auth Adds a (failing) example for fetching home timeline with app-only auth. May 6, 2013
lib Updating app engine example May 7, 2013
lists Adds an example for list-related API methods. May 6, 2013
rate_limit_status_app_auth Adding an example to get rate limit status with app-only auth. May 6, 2013
search Adds an example for search. May 6, 2013
search_app_auth Run gofmt. May 6, 2013
search_cursor Adds a sample for cursoring through search results. May 6, 2013
sign_in Update import for new project. May 7, 2013
stream Adds a streaming example by codingneo. Feb 20, 2015
tweet Add example of query tweet by id Nov 16, 2014
tweet_hydrate Display total number collected Nov 11, 2016
tweet_media Adding an example to tweet with media. May 6, 2013
tweet_place Adding an example to Tweet from a specific place. May 6, 2013
user_timeline Adding an example to fetch a user's timeline. May 6, 2013
user_timeline_app_auth Adding an example to fetch a user's timeline with app-only auth. May 6, 2013
user_timeline_appengine Add a deploy target. May 7, 2013
verify_credentials Adding a verify credentials example. May 6, 2013
video_upload Added an example showing how to upload media. May 22, 2015
.gitignore Update gitignore Feb 21, 2016
.gitmodules Updating app engine example May 7, 2013
CONTRIBUTORS Adding codingneo to contributors list. Feb 20, 2015
LICENSE Adds an explicit license. May 7, 2013
README.md Add note about line endings Aug 23, 2017

README.md

twittergo-examples

These examples should give a good idea of how to use the https://github.com/kurrik/twittergo client library.

Using

First install the following dependencies:

go get -u github.com/kurrik/twittergo
go get -u github.com/kurrik/oauth1a

Then add a file called CREDENTIALS in this project root. The format of this file should be:

<Twitter consumer key>
<Twitter consumer secret>
<Twitter access token>
<Twitter access token secret>

Note: As the examples are written, the end of line char in the CREDENTIALS file must be in UNIX format (LF and not CR+LF) otherwise the authentication fails.

Some examples (like tweet) actually write to the API, so use a testing account!

To run an example:

go run <path to example>/main.go

The simplest example is probably verify_credentials. This calls an endpoint which will return the current user if the request is signed correctly.

App Engine

The Google App Engine examples are a bit more involved, mostly because you need to bundle a copy of the library with your app. To facilitate this I've chosen to utilize git submodules. After checking out this repo, run:

git submodule init
git submodule update

You may need to run git submodule update from time to time as I update the example to use a more current version of the library.

There are some dependencies you'll also need to satisfy. The following only need to be done once per machine:

brew install pkill
sudo npm install -g grunt-cli
<Install Go dev appserver to ~/src/google_appengine_go>

Per-project:

cd <PROJECT_DIR>
npm install
grunt develop

Examples will be accessible on http://localhost:9996.