fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

slackhandler.class.php
Go to the documentation of this file.
1 <?php
2 class SlackHandler extends Slack
3 {
4  private $_apiToken;
5  private static $_apiEndpoint = 'https://slack.com/api/<method>';
6  private $_curlCallback;
7  private static $_methods = array(
8  // api
9  'api.test',
10  // auth
11  'auth.test',
12  // chanels
13  'channels.archive',
14  'channels.create',
15  'channels.history',
16  'channels.info',
17  'channels.invite',
18  'channels.join',
19  'channels.kick',
20  'channels.leave',
21  'channels.list',
22  'channels.mark',
23  'channels.rename',
24  'channels.setPurpose',
25  'channels.setTopic',
26  'channels.unarchive',
27  // chat
28  'chat.delete',
29  'chat.postMessage',
30  'chat.update',
31  // dnd
32  'dnd.endDnd',
33  'dnd.endSnooze',
34  'dnd.info',
35  'dnd.setSnooze',
36  'dnd.teamInfo',
37  // emoji
38  'emoji.list',
39  // files.comments
40  'files.comments.add',
41  'files.comments.delete',
42  'files.comments.edit',
43  // files
44  'files.delete',
45  'files.info',
46  'files.list',
47  'files.upload',
48  // groups
49  'groups.archive',
50  'groups.close',
51  'groups.create',
52  'groups.createChild',
53  'groups.history',
54  'groups.info',
55  'groups.invite',
56  'groups.kick',
57  'groups.leave',
58  'groups.list',
59  'groups.mark',
60  'groups.open',
61  'groups.rename',
62  'groups.setPurpose',
63  'groups.setTopic',
64  'groups.unarchive',
65  // im
66  'im.close',
67  'im.history',
68  'im.list',
69  'im.mark',
70  'im.open',
71  // mpim
72  'mpim.close',
73  'mpim.history',
74  'mpim.list',
75  'mpim.mark',
76  'mpim.open',
77  // oauth
78  'oauth.access',
79  // pins
80  'pins.add',
81  'pins.list',
82  'pins.remove',
83  // reactions
84  'reactions.add',
85  'reactions.get',
86  'reactions.list',
87  'reactions.remove',
88  // rtm
89  'rtm.start',
90  // search
91  'search.all',
92  'search.files',
93  'search.messages',
94  // stars
95  'stars.add',
96  'stars.list',
97  'stars.remove',
98  // team
99  'team.accessLogs',
100  'team.info',
101  'team.integrationLogs',
102  // usergroups
103  'usergroups.create',
104  'usergroups.disable',
105  'usergroups.enable',
106  'usergroups.list',
107  'usergroups.update',
108  // usergroups.users
109  'usergroups.users.list',
110  'usergroups.users.update',
111  // users
112  'users.getPresence',
113  'users.info',
114  'users.list',
115  'users.setActive',
116  'users.setPresence',
117  );
118  public function __construct($apiToken)
119  {
120  $this->_apiToken = $apiToken;
121  if (!function_exists('curl_init')) {
122  throw new SlackException('cURL library is not loaded.');
123  }
124  }
125  public function call($method, $args = array())
126  {
127  if (array_search($method, self::$_methods, true) === false) {
128  throw new SlackException(_('Invalid method called'));
129  }
130  $args['token'] = $this->_apiToken;
131  return json_decode(json_encode($this->_curlRequest(str_replace('<method>', $method, self::$_apiEndpoint), 'POST', $args)), true);
132  }
144  private function _curlRequest($url, $method, $data = null, $sendAsJSON = false, $auth = true)
145  {
146  $data = self::$FOGURLRequests->process($url, $method, $data, $sendAsJSON, ($auth ? $this->_apiToken : false), $this->_curlCallback);
147  return json_decode($data[0]);
148  }
149 }
SlackHandler\$_apiEndpoint
static $_apiEndpoint
Definition: slackhandler.class.php:5
SlackHandler\call
call($method, $args=array())
Definition: slackhandler.class.php:125
SlackHandler\$_curlCallback
$_curlCallback
Definition: slackhandler.class.php:6
SlackException
Definition: slackexception.class.php:3
SlackHandler\$_apiToken
$_apiToken
Definition: slackhandler.class.php:4
FOGController\$data
$data
Definition: fogcontroller.class.php:35
Slack
Definition: slack.class.php:3
SlackHandler\_curlRequest
_curlRequest($url, $method, $data=null, $sendAsJSON=false, $auth=true)
Definition: slackhandler.class.php:144
$url
$url
Definition: kernelvers.php:27
SlackHandler
Definition: slackhandler.class.php:3
SlackHandler\__construct
__construct($apiToken)
Definition: slackhandler.class.php:118
SlackHandler\$_methods
static $_methods
Definition: slackhandler.class.php:7