An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 9.0% on proxy.golang.org

proxy.golang.org : github.com/wangbin/tweetlib

A fully OAuth-authenticated implementation of Twitter's REST API v1.1 See https:dev.twitter.com/docs/api/ Usage example: Twitter uses OAUTH 1.0a for authentication and tweetlib supports the 3-legged authorization method. See https://dev.twitter.com/docs/auth/3-legged-authorization 1. Setup a Config structure with the Consuler Key and Secret found on your application's page. You can create new applications by visiting http://dev.twitter.com/apps/new. Twitter also requires a callback URL that will receive Twitter's token 2. Populate a tweetlibTransport structure with the Config from the previous step and, for now, an empty Token 2a. (Optional) tweetlib.Transport uses the http package to talk to Twitter by default. This may not be possible or desirable. For example, if the Client is to be used in a Google Appengine app, it becomes necessary to change the underlying transport to be used. E.g.: 3. Not it's possible to request the temporary token. This will start the little Oauth dance with Twitter 4. With the tweetlib.TempToken ready, now it's time to request the user to authorize your application. This is done by redirecting the user to the URL returned by tweetlib.TempToken.AuthURL(). (Note that you must save the temporary token as it will be necessary later to request the permanent token) 5. The user will be promted by Twitter to authorize your application. If they authorize it, Twitter will call your callback as set in step 1. Twitter will issue a GET request to your callback with two parameters: 6. Finally, you'll request the permanent token from Twitter Note that you do not need to update your tweetlib.Transport.Token with the new token, as this is done automatically, meaning you can immediatly start making API calls with the same transport. That said, you must save the token for future use so you don't have to go through all this dance again each time. Next time you need to make calls on behalf of a user you already have a token for, you simply set the Transport with the saved token. Using the Twitter API we can obtain an authentication token for only our application Yes it's that easy. Now you have a token that you can use to make API calls We can invalidate a previously obtained application only token by passing it to the InvalidateToken function For making calls based off a users account, making an API call is trivial once authentication is set up. It all starts with getting an API Client object: For making calls for applications only, we can use our previously obtained authentication token and pass it to the application-only client constructor. Unlike utilizing user authenticated APIs, we do not need to use any custom instances of http.Client Once you have the client, you can make API calls easily. For example, to post a tweet as the authenticating user The vast majority of API calls to the Twitter REST API takes one or two required parameters along with any number of optional ones. For example, when updating the status, it is possible to attached geographical coordinates to it via the 'lat' and 'long' optional parameters. To provide optional parameters, use tweetlib.Optionals There's also two ways of making arbitrary API calls. This is useful when you need to call a new API that is not directly supported by tweetlib's utility functions or maybe you want better control of the response objects. The first way is using Client.Call like this: Client.Call will try to unmarshal the response returned from Twitter. If however you wish to do it yourself or maybe not use the types defined by tweetlib (User, Tweet, etc), you can use CallJSON instead: These two functions are usually internally by the many helper functions defined in tweetlib and also add flexibility to tweetlib - 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.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/wangbin/tweetlib
License: BSD-2-Clause
Latest release: over 10 years ago
First release: over 10 years ago
Namespace: github.com/wangbin
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 19 days ago

    Loading...
    Readme
    Loading...