Search and add Twitter users?

Any suggestions for a good Twitter library (preferably in Ruby or Python)? I have a list of usernames, and I need to be able to programmatically follow these users.

  • I tried twitter4r in Ruby, but user search does not work. When i do

    twitter = Twitter::Client.new(:login => 'mylogin', :password => 'mypassword')
    user = Twitter::User.find('ev', twitter)
    

... The user always returned to a specific guy named "Jose Italo", no matter what username I am trying to make.

  1. Similary, I tried python-twitter, but the following users do not seem to work. When i do

    api = twitter.Api(username='mylogin', password='mypassword')
    user = api.GetUser('ev')
    api.CreateFriendship(user)
    

... I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.5-i386/egg/twitter.py", line 1769, in CreateFriendship
  File "build/bdist.macosx-10.5-i386/egg/simplejson/__init__.py", line 307, in loads
  File "build/bdist.macosx-10.5-i386/egg/simplejson/decoder.py", line 335, in decode
  File "build/bdist.macosx-10.5-i386/egg/simplejson/decoder.py", line 353, in raw_decode
ValueError: No JSON object could be decoded

So, any suggestions for a working library or how to make twitter4r or python twitter work?

+3
source share
1

http://github.com/jnunemaker/twitter/ .

, - , HTTP API. : http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-friendships%C2%A0create

Ruby RestClient, :

require "rest_client"
require "json"

r = RestClient.post "http://username:password@twitter.com/friendships/create.json",
        :screen_name => "user_to_follow"
j = JSON.parse(r)

. .

+1

Source: https://habr.com/ru/post/1721029/


All Articles