Skip to content

Instantly share code, notes, and snippets.

@ardeay
Created June 9, 2016 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ardeay/0fd2b295675ee99f784bfb89bffe6757 to your computer and use it in GitHub Desktop.
Save ardeay/0fd2b295675ee99f784bfb89bffe6757 to your computer and use it in GitHub Desktop.
<?php
$_POST['email'] = '';
// slack invite
$group = ''; // team name
$token = ''; // admin token generated at https://api.slack.com/docs/oauth-test-tokens
$data = array(
'email' => $_POST['email'],
'channels' => '',
'first_name' => '',
'token' => trim( $token ),
'set_active' => 'true',
'_attempts' => '1',
);
$slack_url = 'https://' . $group .'.slack.com';
$url = $slack_url . '/api/users.admin.invite?t=1';
//url-ify the data for the POST
foreach($data as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment