I made this code with the pycurl library
import io
import pycurl
from StringIO import StringIO
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://www.twitter.com/")
c.setopt(pycurl.HTTPHEADER, ["Accept:"])
c.setopt(pycurl.COOKIEFILE, "cookieDeLogueoTwitter.txt")
c.setopt(pycurl.REFERER,"http://www.twitter.com/")
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
e = io.BytesIO()
c.setopt(pycurl.WRITEFUNCTION, e.write)
c.perform()
print c.getinfo(pycurl.HTTP_CODE), c.getinfo(pycurl.EFFECTIVE_URL)
content = e.getvalue()
posicion_token = content.find("authenticity_token")
print "El token es"
token = content[posicion_token-48:posicion_token-8]
##
print content[posicion_token-48:posicion_token-8]
##
token = str(token)
print token
c.setopt(pycurl.URL, "https://twitter.com/sessions")
c.setopt(pycurl.HTTPHEADER, ["Accept:"])
c.setopt(pycurl.COOKIEFILE, "cookieDeLogueoTwitter.txt")
c.setopt(pycurl.REFERER,"http://www.twitter.com/")
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
c.setopt(pycurl.POST, 1)
username = "user"
password = "password"
postfields = { "session[username_or_email]" : "usuario" , "session[password]" : "password","return_to_ssl": "true", "scribe_log": "", "redirect_after_login":"%2F", "authenticity_token": token }
print postfields
c.setopt(pycurl.POSTFIELDS, postfields)
and he throws me the following error
Traceback (most recent call last): File "C: \ Users \ User \ Desktop \ instabot-twitbot \ logueo_twitter2.py", line 56, in c.setopt (pycurl.POSTFIELDS, postfields) TypeError: invalid arguments to setopt
But supposedly the argument POSTFIELDS exists according to the examples that there are
What could be the error then?