adnlib

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

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

Go to latest
Published: Jan 2, 2013 License: BSD-3-Clause Imports: 12 Imported by: 1

README

adnlib

Simple Go implementation of app.net API.

Installing

Best way to isntall this package is by running goinstall:

go get github.com/robteix/adnlib

And then you can import it in your code like this:

import (
        ...
        "github.com/robteix/adnlib"
        ...
    )

General use

  1. First create a adnlib.Transport that will handle OAuth:

     config := &Config{
                 ConsumerKey: "your-consumer-key",
                 ConsumerSecret: "your-consumer-secret",
                 Callback: "http://www.my-app.com/my-callback"}
     token := &Token{
                 OAuthSecret: "your-oauth-secret",
                 OAuthToken: "your-oauth-token"}
     tr := &adnlib.Transport{Config: config,
                           Token: token}
    
  2. Create a adnlib object:

     tl := adnlib.New(tr.Client())
    
  3. Post something:

     tl.Stream.Post("this is cool!").Do()
    

TODO: document how to perform the oauth authentication.

License

Copyright 2011 The Tweetlib Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

Overview

adnlib - A fully oauth-authenticated Go Twitter library

Copyright 2011 The Tweetlib Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOAuth = errors.New("OAuth failure")
)

Functions

This section is empty.

Types

type ADNToken

type ADNToken struct {
	Data struct {
		User *User `json:"user"`
	} `json:"data"`
	Meta struct {
		Code int64 `json:"code"`
	} `json:"meta"`
}

type ADNTokenList

type ADNTokenList []ADNToken

type Config

type Config struct {
	ConsumerKey    string
	ConsumerSecret string
	Callback       string
}

type Service

type Service struct {
	Stream *StreamService
	// contains filtered or unexported fields
}

func New

func New(client *http.Client) (*Service, error)

type StreamPostCall

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

func (*StreamPostCall) Do

func (c *StreamPostCall) Do() (*interface{}, error)

func (*StreamPostCall) InReplyTo

func (c *StreamPostCall) InReplyTo(in_reply_to string) *StreamPostCall

type StreamService

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

func (*StreamService) Post

func (r *StreamService) Post(text string) *StreamPostCall

func (*StreamService) Token

func (r *StreamService) Token() *StreamTokenCall

type StreamTokenCall

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

func (*StreamTokenCall) Do

func (c *StreamTokenCall) Do() (*ADNToken, error)

type Token

type Token struct {
	AccessToken string `json:"access_token"`
}

type Transport

type Transport struct {
	*Config
	*Token

	// Transport is the HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	// (It should never be an oauth.Transport.)
	Transport http.RoundTripper
}

func (*Transport) AuthURL

func (t *Transport) AuthURL() string

func (*Transport) Client

func (t *Transport) Client() *http.Client

Client returns an *http.Client that makes OAuth-authenticated requests.

func (*Transport) RequestAccessToken

func (t *Transport) RequestAccessToken(code string) (*Token, error)

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

type User

type User struct {
	Id       string `json:"id"`
	UserName string `json:"username"`
}

type UserList

type UserList []User

Directories

Path Synopsis
misc
gen

Jump to

Keyboard shortcuts

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