Skip to content

Instantly share code, notes, and snippets.

@shakked
Created November 4, 2015 01:26
Show Gist options
  • Save shakked/5fbd13081f80e0dc9066 to your computer and use it in GitHub Desktop.
Save shakked/5fbd13081f80e0dc9066 to your computer and use it in GitHub Desktop.
Follow
func follow(account: Account, user: User, completion : (Bool) -> (Void)) {
let urlString = "https://api.instagram.com/v1/users/\(user.id)/relationship?access_token=\(account.accessToken)"
let parameters = ["action" : "follow"]
let jsonSerialization = try! NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions.PrettyPrinted)
let json = String(data: jsonSerialization, encoding: NSUTF8StringEncoding)!
let dict = ["body" : json]
manager.responseSerializer = AFJSONResponseSerializer()
manager.POST(urlString, parameters: dict, success: { (operation, result) -> Void in
let result = result as! NSDictionary
let data = result["data"] as! NSDictionary
completion(true)
}) { (operation, error) -> Void in
completion(false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment