我正在设置支付网关,我想设置授权标题并发送正文数据,但我不知道如何.
从例证http://perfect.org/docs/cURL.html
let curlObject = CURL(url: "http://www.perfect.org")curlObject.perform { code,header,body in print("Request error code \(code)") print("Response: \(curlObject.responseCode)") print("header: \(header)") print("Body: \(body)")}
我提到这个却没有帮助怎么办?
https://curl.haxx.se/libcurl/c/
解决方法 经过大量的搜索,我找到了一些东西let url = "https://httpbin.org/post"let postParamString = "key1=value1&key2=value2"let byteArray = [UInt8](postParamString.utf8)let curl = CURL(url: url)let _ = curl.setoption(CURLOPT_POST,int: 1)let _ = curl.setoption(CURLOPT_POSTFIELDS,v: UnsafeMutableRawPointer(mutating: byteArray))let _ = curl.setoption(CURLOPT_POSTFIELDSIZE,int: byteArray.count)curl.perform { code,body in print("Request error code \(code) \n Response: \(curl.responseCode) \n header: \(UTF8EnCoding.encode(bytes:header)) \n Body: \(UTF8EnCoding.encode(bytes: body))")}
有关更多信息,请参阅此C示例
https://curl.haxx.se/libcurl/c/example.html
以上是内存溢出为你收集整理的swift – 如何使用Perfect在CURL中发布帖子请求全部内容,希望文章能够帮你解决swift – 如何使用Perfect在CURL中发布帖子请求所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)