Skip to main content
added 58 characters in body
Source Link
JAL
  • 364
  • 4
  • 15

Swift 2.2 on iOS, 380 bytes

let r = NSMutableURLRequest(URL:NSURL(string:"http://codegolf.stackexchange.com/posts/84546/comments")!)
r.HTTPMethod = "POST"
r.HTTPBody = try!NSJSONSerialization.dataWithJSONObject(["comment":"1234567890123456","fkey":UIWebView().stringByEvaluatingJavaScriptFromString("localstorage.getItem('se:fkey')")!],options:[])
NSURLSession.sharedSession().dataTaskWithRequest(r).resume()

Assumes the user is logged in to Code Golf with Safari and has cookies enabled. Also assumes UIKit is implicitly imported and available. JSON serialization is so verbose in Cocoa... Might update this with a Swift 3 solution and optionally macOS/Linux testable answers.

Swift 2.2 on iOS, 380 bytes

let r = NSMutableURLRequest(URL:NSURL(string:"http://codegolf.stackexchange.com/posts/84546/comments")!)
r.HTTPMethod = "POST"
r.HTTPBody = try!NSJSONSerialization.dataWithJSONObject(["comment":"1234567890123456","fkey":UIWebView().stringByEvaluatingJavaScriptFromString("localstorage.getItem('se:fkey')")!],options:[])
NSURLSession.sharedSession().dataTaskWithRequest(r).resume()

Assumes the user is logged in to Code Golf with Safari and has cookies enabled. JSON serialization is so verbose in Cocoa... Might update this with a Swift 3 solution and optionally macOS/Linux testable answers.

Swift 2.2 on iOS, 380 bytes

let r = NSMutableURLRequest(URL:NSURL(string:"http://codegolf.stackexchange.com/posts/84546/comments")!)
r.HTTPMethod = "POST"
r.HTTPBody = try!NSJSONSerialization.dataWithJSONObject(["comment":"1234567890123456","fkey":UIWebView().stringByEvaluatingJavaScriptFromString("localstorage.getItem('se:fkey')")!],options:[])
NSURLSession.sharedSession().dataTaskWithRequest(r).resume()

Assumes the user is logged in to Code Golf with Safari and has cookies enabled. Also assumes UIKit is implicitly imported and available. JSON serialization is so verbose in Cocoa... Might update this with a Swift 3 solution and optionally macOS/Linux testable answers.

Source Link
JAL
  • 364
  • 4
  • 15

Swift 2.2 on iOS, 380 bytes

let r = NSMutableURLRequest(URL:NSURL(string:"http://codegolf.stackexchange.com/posts/84546/comments")!)
r.HTTPMethod = "POST"
r.HTTPBody = try!NSJSONSerialization.dataWithJSONObject(["comment":"1234567890123456","fkey":UIWebView().stringByEvaluatingJavaScriptFromString("localstorage.getItem('se:fkey')")!],options:[])
NSURLSession.sharedSession().dataTaskWithRequest(r).resume()

Assumes the user is logged in to Code Golf with Safari and has cookies enabled. JSON serialization is so verbose in Cocoa... Might update this with a Swift 3 solution and optionally macOS/Linux testable answers.