Maida umarnin CURL zuwa lambar Swift akan layi

Curl command

Examples: GET - POST - JSON - Basic Auth - Files - Form

CURL zuwa Swift akan layi

Wannan kayan aikin yana taimaka muku ƙirƙirar lambar Swift bisa umarnin CURL. Kwafi da liƙa umarnin CURL kuma ƙirƙirar Swift.

Me za ku iya yi da CURL zuwa Swift Converter akan layi?

  • CURL zuwa Swift kayan aiki ne na musamman don canza umarnin CURL zuwa buƙatar Swift na Swift. Shigar da shigarwar ta hanyar umarnin CURL na mai amfani don samar da lambar Swift.
  • Wannan kayan aikin yana adana lokacin ku kuma yana taimakawa ƙirƙirar lambar Swift cikin sauƙi.
  • CURL zuwa Swift yana aiki da kyau akan Windows, MAC, Linux, Chrome, Firefox, Edge da Safari.

menene CURL?

CURL kayan aikin layin umarni ne mai buɗewa wanda ke zazzage fayiloli daga gidan yanar gizo. Yana goyan bayan ka'idoji iri-iri, gami da Swift, SwiftS, FTP, SFTP, TFTP, Gopher da sauransu.

Ta yaya ake canza CURL zuwa Swift code? 

Mataki 1: Manna kuma canza buƙatun CURL ɗin ku zuwa lambar Swift

Mataki 2: Kwafi Swift code

Maida CURL zuwa misali Swift

CURL
curl example.com
PHP Guzzle
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://example.com/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()