我正在尝试获取跟踪我的用户列表,但它似乎没有给我任何结果。这是我正在使用的代码:
func followers(){
print("1")
let url = URL(string: "https://api.instagram.com/v1/users/self/followed-by?access_token=\(self.currentAccessTolken)")
URLSession.shared.dataTask(with:url!, completionHandler: {(data, response, error) in
guard let data = data, error == nil else { return }
print("2")
do {
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! [String:Any]
print("3")
if let userJson = json["data"] as? [String : AnyObject] {
print("4")
if let username = userJson["username"] as? String {
print("username: \(username)")
}
if let fullname = userJson["full_name"] as? String {
print("full name: \(fullname)")
}
}
} catch let error as NSError {
print(error)
}
}).resume()
}
API:https://www.instagram.com/developer/endpoints/relationships/#get_users_followed_by
printn("1")
,printn("2")
和printn("3")
会显示在事件日志中,但不会显示在printn("4")
中。它也没有给我任何用户名或全名的结果。我使用的范围是:basic+follower_list+public_content+relationships
。谁知道这里可能有什么问题?