Post tweet using "python-social-auth"

329 views Asked by At

I'm using python-social-auth to associate twitter with accounts Django and I need post tweets from python, this is my code:

social = user.social_auth.get(provider='twitter')
backend = social.get_backend()
data = {'status': 'Hello'}
response = backend.get_json(
    'https://api.twitter.com/1.1/statuses/update.json',
    method='POST',
    auth=backend.oauth_auth(social.extra_data['access_token']),
    data=data
)

The result is this error: TypeError: unbound method oauth_auth() must be called with TwitterOAuth instance as first argument (got dict instance inst ead)

Then use:

backend = social.get_backend_instance()

But, The result is:

AttributeError: 'NoneType' object has no attribute 'find'

The version of python-social-auth:

python-social-auth==0.2.10 and Django==1.8.2

Traceback:

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "/Users/jrperdomoz/.virtualenvs/venv/lib/python2.7/site-packages/social/backends/oauth.py", line 289, in oauth_auth
    callback_uri=self.get_redirect_uri(state),
  File "/Users/jrperdomoz/.virtualenvs/venv/lib/python2.7/site-packages/social/backends/oauth.py", line 98, in get_redirect_uri
    uri = url_add_parameters(uri, {'redirect_state': state})
  File "/Users/jrperdomoz/.virtualenvs/venv/lib/python2.7/site-packages/social/utils.py", line 68, in url_add_parameters
    fragments = list(urlparse(url))
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 143, in urlparse
    tuple = urlsplit(url, scheme, allow_fragments)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 182, in urlsplit
    i = url.find(':')
AttributeError: 'NoneType' object has no attribute 'find'

Thanks

0

There are 0 answers