how to parse copy link of twitter

Viewed 210

I am using this code -:

private static func getJson(_ link: String, completion: @escaping (Json?) -> ()) {
    let url = URL(string: "https://twitter.com/BCCI/status/1476041561288822788?s=20")!
    URLSession.shared.dataTask(with: url) { data, response, error in
        guard let data = data, error == nil else {
            return completion(nil)
        }
        if let json = (try? JSONSerialization.jsonObject(with: data)) as? Json {
            completion(json)
        } else {
            completion(nil)
        }
    }.resume()
}

I want to get json data and download the link

1 Answers

If we take a look at the Twitter docs here you'll see that it requires authentication hence the error when making the call.

Auth: Twitter Oauth 1.0, app-only or app-user

This Twitter getting started link may be useful to get setup to do so, it's fairly self explanatory and goes step by step.

Related