更新时间:2022-05-06 21:49:58
最简单的方法是三次调用curl_easy_setopt
CURLOPT_POST
告诉图书馆你要发帖子。CURLOPT_POSTFIELDS
告诉库这是一个指向您希望以服务器期望的形式发送的数据的指针。您可以确保此格式正确无误。如果您正在使用XML期望的Web服务,那么您将构建XML,libCurl将无济于事。CURLOPT_POSTFIELDSIZE
告诉图书馆你要发送的数据的大小。
或者你可以阅读 curl_easy_setopt [ ^ ] docs并了解如何使用回调来形成数据 - 但是否需要它取决于您与服务器的交互方式。
The simplest way is three calls tocurl_easy_setopt
CURLOPT_POST
tells the library that you're going to do a post.CURLOPT_POSTFIELDS
tells the library that this is a pointer to the data that you want to send in exactly the form the server expects it. It's up to you to make sure that this format is correct. If you're using an XML expecting webservice you get to form the XML, libCurl won't help.CURLOPT_POSTFIELDSIZE
tells the library the size of the data you want sent.
Alternatively you can read the curl_easy_setopt[^] docs and see how you can use a callback to form the data - but whether you need that depends on how you interact with the server.