Created
November 4, 2015 01:26
-
-
Save shakked/5fbd13081f80e0dc9066 to your computer and use it in GitHub Desktop.
Follow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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