-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathclient.swift
executable file
·42 lines (37 loc) · 1.18 KB
/
client.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/swift
//
// client.swift
// for instagrapi-rest
//
//
import Foundation
let BaseUrl = "http://localhost:8000"
func getVersion() {
let url = URL(string: "\(BaseUrl)/version")!
let sem = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
guard let data = data else { return }
print("\nVersion:", String(data: data, encoding: .utf8)!)
sem.signal()
}
task.resume()
sem.wait()
}
//func pkFromCode(code: String) {
// // let url = URL(string: "\(BaseUrl)/media/pk_from_code")!
// let queryItems = URLQueryItem(name: "code", value: code)
// var urlComps = URLComponents(string: "\(BaseUrl)/media/pk_from_code")
// urlComps.queryItems = queryItems
// let url = urlComps.url!
// let sem = DispatchSemaphore(value: 0)
// let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
// guard let data = data else { return }
// print("\npkFromCode: \(code) ->", String(data: data, encoding: .utf8)!)
// sem.signal()
// }
// task.resume()
// sem.wait()
//}
getVersion()
//pkFromCode(code: "B1LbfVPlwIA")
// dump(Process.arguments)