Giter Site home page Giter Site logo

twitter.jl's Introduction

Twitter.jl

A Julia package for interacting with the Twitter API.

Linux: Build Status

CodeCov: codecov

Twitter.jl is a Julia package to work with the Twitter API v1.1. Currently, only the REST API methods are supported; streaming API endpoints aren't implemented at this time.

All functions have required arguments for those parameters required by Twitter and an options keyword argument to provide a Dict{String, String} of optional parameters Twitter API documentation. Most function calls will return either a Dict or an Array <: TwitterType. Bad requests will return the response code from the API (403, 404, etc).

DataFrame methods are defined for functions returning composite types: Tweets, Places, Lists, and Users.

Authentication

Before one can make use of this package, you must create an application on the Twitter's Developer Platform.

Once your application is approved, you can access your dashboard/portal to grab your authentication credentials from the "Details" tab of the application.

Note that you will also want to ensure that your App has Read / Write OAuth access in order to post tweets. You can find out more about this on Stack Overflow.

Installation

To install this package, enter ] on the REPL to bring up Julia's package manager. Then add the package:

julia> ]
(v1.7) pkg> add Twitter

Tip: Press Ctrl+C to return to the julia> prompt.

Usage

To run Twitter.jl, enter the following command in your Julia REPL

julia> using Twitter

Then the a global variable has to be declared with the twitterauth function. This function holds the consumer_key(API Key), consumer_secret(API Key Secret), oauth_token(Access Token), and oauth_secret(Access Token Secret) respectively.

twitterauth("6nOtpXmf...", # API Key
            "sES5Zlj096S...", # API Key Secret
            "98689850-Hj...", # Access Token
            "UroqCVpWKIt...") # Access Token Secret
  • Ensure you put your credentials in an env file to avoid pushing your secrets to the public ๐Ÿ™€.

Note: This package does not currently support OAuth authentication.

Code examples

See runtests.jl for example function calls.

Want to contribute?

Contributions are welcome! Kindly refer to the contribution guidelines.

twitter.jl's People

Contributors

aj-michael avatar alexander-barth avatar alexpkeil1 avatar femtocleaner[bot] avatar gbaraldi avatar ifihan avatar juliatagbot avatar logankilpatrick avatar matbesancon avatar pkofod avatar randyzwitch avatar simondanisch avatar stefanjwojcik avatar tkelman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitter.jl's Issues

Getting 403 bad requests when running post status

Hey! I have been trying to help a few students who are writing Twitter bots using Twitter.jl.

When I get their code and run it, I always get 403 bad requests. Do you have any idea why this would be? The code is seemingly working for them, and I am trying to validate the completion of the task, but I can't.

Thanks!

post_status_update with media?

using Twitter
twitterauth(...)
post_status_update(status="Test tweet")

works fine for me, but how does one include media, e.g. a png file? TwitterAPI seems to implement it as

api = TwitterAPI(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
file = open('Your_image.png', 'rb')
data = file.read()
r = api.request('statuses/update_with_media', {'status':'Your tweet'}, {'media[]':data})

with data being of type bytes

In [4]: type(open("folder/file.png","rb").read())
Out[4]: bytes

Unable to run post_status_update function

Here is the error I am getting when running on Julia 1.3:

[ Info: Precompiling Twitter [92393bbf-ba23-5323-a3fa-fbe1e5f35af8]
ERROR: LoadError: MethodError: no method matching post_status_update(::String)
Closest candidates are:
  post_status_update(; kwargs...) at /Users/logankilpatrick/.julia/packages/Twitter/4Yzhi/src/macrogenerated.jl:92

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Twitter.jl on a 32-bit platform (Raspberry Pi)

Thanks for this nice package!

I try to use Twitter.jl on a Rasberry Pi, but I have the following error (while it works on a 64-bit Linux):

Twitter.post_status_update(status = "Test")
# returns
# ERROR: InexactError: trunc(Int32, 1180186675730898944)
# Stacktrace:
# [1] throw_inexacterror(::Symbol, ::Any, ::Int64) at ./boot.jl:567

On 32-bit platforms, Int has just 32-bits. I propose to use actually Int64 for all IDs.
See also https://blog.twitter.com/developer/en_us/a/2013/64-bit-twitter-user-idpocalypse.html

I will submit a PR.

I am using Julia 1.0.3.

Support pre-compiling and 0.4

Now that v0.4RC1 out, make sure everything works for 0.4, as well as support pre-compiling (although I think it would be negligible for this package)

Incorporate backoff when Twitter API throws 'Too many requests'

Ref: #33

With new changes to test suite for cursoring, Twitter API now throttles with error message of too many requests. Package works (I've tested locally), just need to figure out which test causes an issue and fix it.

The issue doesn't appear to be new test related, but rather than CI kicks off so many test suites simultaneously. Will turn off some Julia versions, but would also be good to have a API backoff implemented when Twitter warns to slow down.

cc: @stefanjwojcik

https://travis-ci.org/randyzwitch/Twitter.jl/jobs/642186424

Problems with parse()

Hi!

I planned on giving your Twitter package a whirl today (having had some good experiences with a similar package in R), but I ran into a bit of a problem. Authentication went fine but then when I tried a range of functions I ended up getting the same error message:

julia> get_mentions_timeline();
ERROR: `parse` has no method matching parse(::Array{Uint8,1})
julia> get_retweets_id("434685122671939584")
ERROR: `parse` has no method matching parse(::Array{Uint8,1})
 in get_retweets_id at /home/colliera/.julia/v0.3/Twitter/src/tweets.jl:13
julia> get_help_languages()
ERROR: `parse` has no method matching parse(::Array{Uint8,1})
julia> get_lists()
ERROR: `parse` has no method matching parse(::Array{Uint8,1})

Do you have an idea what the issue might be? I am running Julia 0.3.10 (2015-06-24 13:54 UTC) on a 64 bit Linux machine. The Twitter package was installed fresh today using Pkg.add().

Best regards,
Andrew.

get_lists_members returning empty list

get_lists_members is trying to parse a list of users. If you change

(:get_oauth, :get_lists_members3, "lists/members.json", :Users)

to

(:get_oauth, :get_lists_members3, "lists/members.json", nothing)

You get an object that looks like:

Dict{String,Any} with 6 entries:
  "previous_cursor_str" => "5827030161598877703"
  "users"               => Any[Dict{String,Any}("time_zone"=>nothing,"created_at"=>...
  "total_count"         => nothing
  "previous_cursor"     => 5827030161598877703
  "next_cursor"         => 5827030161598877703
  "next_cursor_str"     => "5827030161598877703"

where the "users" values looks like what you are after with this function, but Users(JSON.parse(String(r.body))) doesn't read that in properly. I'd do a pull request, but I'm actually not sure how to fix this here.

Update package dependencies

DataFrames specifically has made some breaking changes from 0.18 to 0.20, should update and release a new version

Make Proper Docs

Hey @randyzwitch!

It seems the next step for this package is to make proper documentation. I've fiddled with the Documenter.jl package, and I think I can manage this.

I have two questions before diving in: 1) Do I expand out all the macrogenerated functions so that we can make real docstrings for them? 2) Do we want to make every function visible in the docs or just the ones that get exported? Pardon my ignorance here.... Thanks!

[feature] Academic API v2

Hi there, I'm thinking to develop some of my dirty and nasty code for the Academic Twitter API as a new package or an extension of this package.

Would anybody be interested in it? See https://github.com/cjbarrie/academictwitteR for an example in R.
Would that be within the scope of Twitter.jl or would people prefer to have it a part from it?

[PackageEvaluator.jl] Your package Twitter may have a testing issue.

This issue is being filed by a script, but if you reply, I will see it.

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their test (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3).

The results of this script are used to generate a package listing enhanced with testing results.

The status of this package, Twitter, on...

  • Julia 0.2 is 'Tests fail, but package loads.' PackageEvaluator.jl
  • Julia 0.3 is 'Tests fail, but package loads.' PackageEvaluator.jl

'No tests, but package loads.' can be due to their being no tests (you should write some if you can!) but can also be due to PackageEvaluator not being able to find your tests. Consider adding a test/runtests.jl file.

'Package doesn't load.' is the worst-case scenario. Sometimes this arises because your package doesn't have BinDeps support, or needs something that can't be installed with BinDeps. If this is the case for your package, please file an issue and an exception can be made so your package will not be tested.

This automatically filed issue is a one-off message. Starting soon, issues will only be filed when the testing status of your package changes in a negative direction (gets worse). If you'd like to opt-out of these status-change messages, reply to this message.

Post methods don't work

Running the following code:

status_update = post_status_update("This blog post I'm writing now about Twitter.jl would be a lot cooler if I did actually create a Twitter bot #julialang")
`post` has no method matching post(::URI, ::ASCIIString, ::Dict{Any,Any})
while loading In[9], in expression starting on line 3
 in post_status_update at /home/rzwitch/.julia/v0.3/Twitter/src/tweets.jl:45

Suspicious "Endpoint exhausted" error message

I'm getting the Endpoint exhausted, sleeping for $sleeptime seconds.. error message, although I don't believe I'm anywhere the API rate limits... How can I debug this? And could this be triggered by some other issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.