English 中文(简体)
Trouble with pycurl. POSTFIELDS
原标题:Trouble with pycurl.POSTFIELDS

我在PHP中熟知CURL,但第一次用这种语言在Avul和Pycurl使用。

我保留错误:

Exception Type:     error
Exception Value:    (2,   )

我不知道这可能意味着什么。 我的守则是:

data = { cmd :  _notify-synch ,
         tx : str(request.GET.get( tx )),
         at : paypal_pdt_test
        }

post = urllib.urlencode(data)

b = StringIO.StringIO()

ch = pycurl.Curl()
ch.setopt(pycurl.URL,  https://www.sandbox.paypal.com/cgi-bin/webscr )
ch.setopt(pycurl.POST, 1)
ch.setopt(pycurl.POSTFIELDS, post)
ch.setopt(pycurl.WRITEFUNCTION, b.write)
ch.perform()
ch.close()

这一错误指的是<代码>ch.setopt(pycurl)。 POSTFIELDS,员额

最佳回答

看来,你安装的花.(或盖尔图书馆)有些how。 更正错误代码文件:

CURLE_FAILED_INIT (2)
Very early initialization code failed. This is likely to be an internal error or problem.

您可能需要重新安装或更换曲线或伪装。

然而,为了像你一样,提出简单的《人口统计》要求,你实际上可以使用“文盲”这一字眼,而不是使用《欧洲增长与增长:

import urllib

postdata = urllib.urlencode(data)

resp = urllib.urlopen( https://www.sandbox.paypal.com/cgi-bin/webscr , data=postdata)

# resp is a file-like object, which means you can iterate it,
# or read the whole thing into a string
output = resp.read()

# resp.code returns the HTTP response code
print resp.code # 200

# resp has other useful data, .info() returns a httplib.HTTPMessage
http_message = resp.info()
print http_message[ content-length ]  #  1536  or the like
print http_message.type  #  text/html  or the like
print http_message.typeheader #  text/html; charset=UTF-8  or the like


# Make sure to close
resp.close()

to open an https:// URL, you may need to install PyOpenSSL: http://pypi.python.org/pypi/pyOpenSSL

某些分歧包括这一点,另一些人则通过你的优惠一揽子管理人员将其作为一种额外的一揽子权利。


<><>Edit>: 您是否称“pycurl.global_init(,但? 我仍然尽可能建议使用urllib/urllib,因为你的文字将更容易转移到其他系统。

问题回答

我这样说:

post_params = [
    ( ASYNCPOST ,True),
    ( PREVIOUSPAGE , yahoo.com ),
    ( EVENTID ,5),
]
resp_data = urllib.urlencode(post_params)
mycurl.setopt(pycurl.POSTFIELDS, resp_data)
mycurl.setopt(pycurl.POST, 1)
...
mycurl.perform()

我知道这是一个老的岗位,但我刚刚花了今天上午的时间来追踪这一错误。 由此可见,在7.16.2.1 <> >上安装了一种粉末,导致四舍五入(>)冲破64-借机。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签