我試圖用libcurl構造一個HTTP表單,但是我無法讓它正常工作。每次我撥打curl_formadd
時,都會返回CURL_FORMADD_OPTION_TWICE
。關於這個錯誤的唯一信息表明libcurl認爲我試圖添加兩個具有相同名稱的表單元素,即使它第一次調用curl_formadd
,而我只添加了一個元素!curl_formadd在第一次調用時返回`CURL_FORMADD_OPTION_TWICE`
Declare Function curl_global_init Lib "libcurl" (flags As Integer) As Integer
Declare Function curl_formadd Lib "libcurl" (FirstItem As Ptr, LastItem As Ptr, Option1 As Integer, Value1 As Ptr, Option2 As Integer, Value2 As Ptr, EndMarker As Integer) As Integer
Const CURLFORM_COPYCONTENTS = 2
Const CURLFORM_COPYNAME = 1
Const CURLFORM_END = 17
Dim formname, formvalue As MemoryBlock
formname = "NAME"
formvalue = "CONTENTS"
If curl_global_init(3) = 0 Then
Dim first, last As Ptr
Dim err As Integer
err = curl_formadd(first, last, CURLFORM_COPYNAME, formname, CURLFORM_COPYCONTENTS, formvalue, CURLFORM_END)
Break
' err is 2 (CURL_FORMADD_OPTION_TWICE)
End If
什麼是這個錯誤試圖告訴我?
謝謝,但我仍然得到'CURL_FORMADD_OPTION_TWICE'。 –
錯誤代碼2並不意味着CURL_FORMADD_OPTION_TWICE,而是列出瞭如下所述的錯誤代碼:「非零意味着發生了錯誤,對應於在中定義的CURL_FORMADD_ *常量」 –
「CURL_FORMADD_OPTION_TWICE」是具有「CURL_FORMADD_ *值爲2.如果這不正確,'2'表示什麼? –