curl-and-python

What is pycurl equivalent of this command?

From: Yaşar Arabacı <yasar11732_at_gmail.com>
Date: Fri, 2 Sep 2011 11:59:13 +0300

Hi,

I was trying to produce this call with pycurl, but couldn't succeed. I am
getting an 400 error. What I am trying to do is:

curl https://www.googleapis.com/urlshortener/v1/url \
  -H 'Content-Type: application/json' \
  -d '{"longUrl": "http://www.google.com/"}'

What I did is:
# defined api, url, json outputter here...
c = pycurl.Curl()
c.setopt(pycurl.URL,api)
c.setopt(pycurl.POST,1)
c.setopt(pycurl.HTTPHEADER, ["Content-Type: application/json"])
c.setopt(pycurl.READFUNCTION, JsonOutputter(url).read)
c.setopt(pycurl.SSL_VERIFYPEER,0)
c.setopt(pycurl.SSL_VERIFYHOST,0)
c.perfom()

-- 
http://yasar.serveblog.net/

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2011-09-02