twitter

package module
v0.0.0-...-dc07964 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2012 License: Apache-2.0 Imports: 15 Imported by: 0

README

============
go-twitter
============

go-twitter is a Twitter library package for Go. The interface is similar to 
python-twitter.


Installation
============

#. Make sure you have Go installed and your environment is set up
   correctly: $GOROOT, $GOARCH, $GOBIN, etc.

#. Checkout the code from the repository or extract the source code.

#. cd go-twitter && make install


Quick Start
===========

::

  import (
    "go-twitter"
    "fmt"

  )
  // Prints the public timeline
  func main() {
    api := twitter.NewApi();
    pubTimeline := <-api.GetPublicTimeline();

    for i, status := range pubTimeline {
      fmt.Printf("#%d %s: %s\n", i,
                status.GetUser().GetScreenName(),
                status.GetText());
    }
  }


Documentation
=============

doc/ - godoc generated files, site coming soon

Documentation

Overview

Copyright 2009 Bill Casarin <billcasarin@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2009 Bill Casarin <billcasarin@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2009 Bill Casarin <billcasarin@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2009 Bill Casarin <billcasarin@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	// contains filtered or unexported fields
}

func NewApi

func NewApi() *Api

Creates and initializes new Api objec

func (*Api) ClearCredentials

func (self *Api) ClearCredentials()

Disable Twitter authentication, subsequent REST calls will not use Authentication

func (*Api) GetErrorChannel

func (self *Api) GetErrorChannel() <-chan error

Returns a channel which receives API errors. Can be used for logging errors.

monitorErrors - listens to api errors and logs them

func monitorErrors(quit chan bool, errors <-chan os.Error) {
  for ;; {
    select {
    case err := <-errors:
      fmt.Fprintf(os.Stderr, err.String());
      break;
    case <-quit:
      return;
    }
  }
}

func (*Api) GetFollowers

func (self *Api) GetFollowers(user interface{}, page int) <-chan []User

Gets the followers for a given user represented by a slice of twitter.User instances

user:

A user id or name to fetch the followers from. If this argument
is nil, then the followers are fetched from the authenticated user.
This paramater must be an int, int64, or string.

page:

Not yet implemented

func (*Api) GetFriends

func (self *Api) GetFriends(user interface{}, page int) <-chan []User

Gets the friends for a given user represented by a slice of twitter.User instances

user:

A user id or name to fetch the friends from. If this argument
is nil, then the friends are fetched from the authenticated user.
This paramater must be an int, int64, or string.

page:

Not yet implemented

func (*Api) GetFriendsTimeline

func (self *Api) GetFriendsTimeline() <-chan []Status

Returns the 20 most recent statuses posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web. Returns the statuses as a slice of Status objects

func (*Api) GetLastError

func (self *Api) GetLastError() error

Returns the last error sent to the error channel. Calling this function pops the last error, subsequent calls will be nil unless another error has occured.

func (*Api) GetPublicTimeline

func (self *Api) GetPublicTimeline() <-chan []Status

Retrieves the public timeline as a slice of Status objects

func (*Api) GetRateLimitInfo

func (self *Api) GetRateLimitInfo() <-chan RateLimit

Returns rate limiting information

func (*Api) GetReplies

func (self *Api) GetReplies() <-chan []Status

Returns the 20 most recent mentions for the authenticated user Returns the statuses as a slice of Status objects

func (*Api) GetStatus

func (self *Api) GetStatus(id int64) <-chan Status

Gets a Twitter status given a status id

The twitter.Api instance must be authenticated if the status message is private

Returns: a channel which receives a twitter.Status object when

the request is completed

func (*Api) GetUser

func (self *Api) GetUser(name string) <-chan User

Returns a channel which receives a twitter.User instance for the given username.

name:

The screenname of the user

func (*Api) GetUserById

func (self *Api) GetUserById(id int64) <-chan User

Returns a channel which receives a twitter.User instance for the given username.

id:

A twiter user id

func (*Api) GetUserTimeline

func (self *Api) GetUserTimeline() <-chan []Status

Retrieves the currently authorized user's timeline as a slice of Status objects

func (*Api) HasErrors

func (self *Api) HasErrors() bool

Checks to see if there are any errors in the error channel

func (*Api) PostUpdate

func (self *Api) PostUpdate(status string, inReplyToId int64) <-chan bool

Post a Twitter status message to the authenticated user

The twitter.Api instance must be authenticated

func (*Api) Search

func (self *Api) Search(query string, page int, perPage int, sinceId int, locale string, lang string) <-chan []SearchResult

Performs a Twitter search. Returns a slice of twitter.SearchResult instances string fields are automatically URL Encoded query:

The string of text to search for.

page:

The page of results to return. Set to 0 to use the default value.

perPage:

The number of results per page. Set to 0 to use the default value.

sinceId:

Return tweets with status ids greater than the given id. Set to 0
to use the default value.

locale:

Specify the language of the query you are sending (only ja is currently
effective). This is intended for language-specific clients and the default
should work in the majority of cases. Set to an empty string to use
the default value.

lang:

Restricts tweets to the given language, given by an ISO 639-1 code.
Set to an empty string to use the default value.

func (*Api) SearchSimple

func (self *Api) SearchSimple(query string) <-chan []SearchResult

Performs a simple Twitter search. Returns a slice of twitter.SearchResult instances

query:

The string of text to search for. This is URL encoded automatically.

func (*Api) SetClientString

func (self *Api) SetClientString(client string)

Sets the Twitter client header, aka the X-Twitter-Client http header on all POST operations

func (*Api) SetCredentials

func (self *Api) SetCredentials(username, password string)

Sets the username and password string for all subsequent authorized HTTP requests

func (*Api) SetReceiveChannel

func (self *Api) SetReceiveChannel(receiveChannel interface{})

func (*Api) SetUserAgent

func (self *Api) SetUserAgent(agent string)

Overrides the default user agent (go-twitter)

func (*Api) SetXTwitterHeaders

func (self *Api) SetXTwitterHeaders(client, url_, version string)

Set the X-Twitter HTTP headers that will be sent to the server.

client:

The client name as a string.  Will be sent to the server as
the 'X-Twitter-Client' header.

url:

The URL of the meta.xml as a string.  Will be sent to the server
as the 'X-Twitter-Client-URL' header.

version:

The client version as a string.  Will be sent to the server
as the 'X-Twitter-Client-Version' header.

type RateLimit

type RateLimit interface {
	GetRemainingHits() int
	GetHourlyLimit() int
	GetResetTimeInSeconds() int64
	GetResetTime() string
}

type SearchResult

type SearchResult interface {
	GetCreatedAt() string
	GetFromUser() string
	GetToUserId() int64
	GetText() string
	GetId() int64
	GetFromUserId() int64
	GetGeo() string
	GetIsoLanguageCode() string
	GetSource() string
}

type Status

type Status interface {
	GetCreatedAt() string
	GetCreatedAtInSeconds() int64
	GetFavorited() bool
	GetId() int64
	GetText() string
	GetInReplyToScreenName() string
	GetInReplyToStatusId() int64
	GetInReplyToUserId() int64
	GetNow() int
	GetUser() User
	// contains filtered or unexported methods
}

type TwitterError

type TwitterError struct {
	// contains filtered or unexported fields
}

func (TwitterError) Error

func (self TwitterError) Error() string

type that satisfies the os.Error interface

type User

type User interface {
	GetId() int64
	GetName() string
	GetScreenName() string
	GetLocation() string
	GetDescription() string
	GetProfileImageUrl() string
	GetProfileBackgroundTitle() bool
	GetProfileBackgroundImageUrl() string
	GetProfileSidebarFillColor() string
	GetProfileLinkColor() string
	GetProfileTextColor() string
	GetProtected() bool
	GetUtcOffset() int
	GetTimeZone() string
	GetURL() string
	GetStatus() Status

	GetStatusesCount() int
	GetFollowersCount() int
	GetFriendsCount() int
	GetFavoritesCount() int
	// contains filtered or unexported methods
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL