↩️ Hooks (http://hooks.events)
This file contains 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
// by @itskathuria | |
NSURL *url = [NSURL URLWithString:@"http://hooks.events/hooks/post.php"]; | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; | |
[request setHTTPMethod:@"POST"]; | |
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; | |
NSString *apiKey = @"yourAPIKeyShouldGoHere"; | |
NSString *title = @"yourTitleShouldGoHere"; | |
NSString *message = @"yourMessageShouldGoHere"; | |
NSString *query = [NSString stringWithFormat:@"hooksTitle=%@&hooksMessage=%@&hooksApi=%@", title, message, apiKey]; | |
NSData *data = [query dataUsingEncoding:NSUTF8StringEncoding]; | |
[request setHTTPBody:data]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { | |
NSLog(@"responseData: %@, error: %@: responseItself: %@", data, connectionError, response); | |
}]; |
This file contains 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
<?php | |
$data = [ | |
'hooksTitle' => 'Hello world', | |
'hooksMessage' => 'I happen to exist as a PHP message', | |
'hooksApi' => 'YOUR API KEY' // http://hooks.events/ | |
]; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'http://hooks.events/hooks/post.php'); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_exec($ch); | |
curl_close ($ch); |
This file contains 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
#!/usr/bin/python | |
import urllib | |
import urllib2 | |
data = { | |
'hooksTitle' : 'Hello world', | |
'hooksMessage' : 'I happen to exist as a Python message', | |
'hooksApi' : 'YOUR API KEY' # http://hooks.events/ | |
} | |
url = 'http://hooks.events/hooks/post.php' | |
req = urllib2.Request(url, urllib.urlencode(data)) | |
urllib2.urlopen(req) |
This file contains 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
require 'net/http' | |
require 'uri' | |
data = { | |
'hooksTitle' => 'Hello World', | |
'hooksMessage' => 'I happen to exist as a Ruby message', | |
'hooksApi' => 'YOUR API KEY' # http://hooks.events/ | |
} | |
uri = URI.parse('http://hooks.events/hooks/post.php') | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Post.new(uri.request_uri) | |
request.set_form_data(data) | |
http.request(request) |
This file contains 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
// Uncomment if running in a Playground | |
// import XCPlayground | |
// XCPSetExecutionShouldContinueIndefinitely() | |
let url = NSURL(string: "http://hooks.events/hooks/post.php") | |
let request = NSMutableURLRequest(URL: url) | |
request.HTTPMethod = "POST" | |
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") | |
let title = "Hello World" | |
let message = "I happen to exist as a Swift message" | |
let api = "YOUR API KEY" // http://hooks.events/ | |
let raw = "hooksTitle=\(title)&hooksMessage=\(message)&hooksApi=\(api)" | |
let data = (raw as NSString).dataUsingEncoding(NSUTF8StringEncoding) | |
request.HTTPBody = data | |
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in | |
println(NSString(data: data, encoding: NSUTF8StringEncoding)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment