Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:09
Show Gist options
  • Save stursby/0e6bb16dce440c8c3052 to your computer and use it in GitHub Desktop.
Save stursby/0e6bb16dce440c8c3052 to your computer and use it in GitHub Desktop.
↩️ Hooks (
// by @itskathuria
NSURL *url = [NSURL URLWithString:@""];
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);
$data = [
'hooksTitle' => 'Hello world',
'hooksMessage' => 'I happen to exist as a PHP message',
'hooksApi' => 'YOUR API KEY' //
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
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_close ($ch);
import urllib
import urllib2
data = {
'hooksTitle' : 'Hello world',
'hooksMessage' : 'I happen to exist as a Python message',
'hooksApi' : 'YOUR API KEY' #
url = ''
req = urllib2.Request(url, urllib.urlencode(data))
require 'net/http'
require 'uri'
data = {
'hooksTitle' => 'Hello World',
'hooksMessage' => 'I happen to exist as a Ruby message',
'hooksApi' => 'YOUR API KEY' #
uri = URI.parse('')
http =, uri.port)
request =
// Uncomment if running in a Playground
// import XCPlayground
// XCPSetExecutionShouldContinueIndefinitely()
let url = NSURL(string: "")
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" //
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