0

我需要通过 POST 发送数据。有这个例子,但不知道如何在 django 中做到这一点。有人可以帮忙吗

例子 :

curl https://ws.pagseguro.uol.com.br/v2/checkout/ -d\
    "email=suporte@lojamodelo.com.br\
    &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\
    &senderEmail=comprador@uol.com.br\
    &shippingType=1\
    &shippingAddressStreet=Av. Brig. Faria Lima\
    &shippingAddressNumber=1384\
    &shippingAddressComplement=5o andar\
    &shippingAddressDistrict=Jardim Paulistano\
    &shippingAddressPostalCode=01452002\
    &shippingAddressCity=Sao Paulo\
    &shippingAddressState=SP\
    &shippingAddressCountry=BRA"
4

1 回答 1

1

你可能想看看 requests 库,但是一个简单的 POST 只需要 python 内置的东西:

import urllib
import urllib2
data = urllib.urlencode({"email":"suporte@lojamodelo.com.br","token":...})
req = urllib2.Request("https://ws.pagseguro.uol.com.br/v2/checkout/", data)
response = urllib2.urlopen(req)
于 2013-10-16T22:05:25.063 回答