Ricardo
Ricardo

Reputation: 25

pass post data curl django

I need to send data by POST. There is this example but do not know how to do this in django. Can someone help

Example :

curl https://ws.pagseguro.uol.com.br/v2/checkout/ -d\
    "[email protected]\
    &token=95112EE828D94278BD394E91C4388F20\
    &currency=BRL\
    &itemId1=0001\
    &itemDescription1=Notebook Prata\
    &itemAmount1=24300.00\
    &itemQuantity1=1\
    &itemWeight1=1000\
    &itemId2=0002\
    &itemDescription2=Notebook Rosa\
    &itemAmount2=25600.00\
    &itemQuantity2=2\
    &itemWeight2=750\
    &reference=REF1234\
    &senderName=Jose Comprador\
    &senderAreaCode=11\
    &senderPhone=56273440\
    &[email protected]\
    &shippingType=1\
    &shippingAddressStreet=Av. Brig. Faria Lima\
    &shippingAddressNumber=1384\
    &shippingAddressComplement=5o andar\
    &shippingAddressDistrict=Jardim Paulistano\
    &shippingAddressPostalCode=01452002\
    &shippingAddressCity=Sao Paulo\
    &shippingAddressState=SP\
    &shippingAddressCountry=BRA"

Upvotes: 0

Views: 963

Answers (1)

Nathan Jhaveri
Nathan Jhaveri

Reputation: 1864

You might want to take a look at the requests library, but a simple POST does not require anything more than what comes built in to python:

import urllib
import urllib2
data = urllib.urlencode({"email":"[email protected]","token":...})
req = urllib2.Request("https://ws.pagseguro.uol.com.br/v2/checkout/", data)
response = urllib2.urlopen(req)

Upvotes: 1

Related Questions