-
Notifications
You must be signed in to change notification settings - Fork 1
/
sendMessage.php
executable file
·50 lines (36 loc) · 1.13 KB
/
sendMessage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/php
<?php
define("AUTHCACHE", "/tmp/auth_info");
define("XUIDCACHE", "/tmp/xuid");
define("EXPIRES", "/tmp/session_expires");
require_once 'XboxLiveClient.php';
if (file_exists(AUTHCACHE) && file_exists(XUIDCACHE)) {
$xuid = file_get_contents(XUIDCACHE);
$authorization_header = file_get_contents(AUTHCACHE);
try {
$live = XboxLiveClient::withCachedCredentials($xuid, $authorization_header);
}
catch (Exception $e) {
printf("Couldn't go with cached creds with message '%s'\n", $e->getMessage());
exit;
}
}
$shortopts = "";
$shortopts .= "g:";
$shortopts .= "m:";
$options = getopt($shortopts);
if (!array_key_exists('g', $options)) {
printf("pass -g<gamertag(s)>\nComma separate multiple recipients\n");
exit;
}
if (!array_key_exists('m', $options)) {
printf("pass -m\"<message\"");
exit;
}
$gts = explode(",",$options['g']);
foreach($gts AS $gt) {
$recipients[] = $live->fetchXuidForGamertag($gt);
}
$message = $options['m'];
//$live->xuid = '2533274868737812';
$live->sendMessage($recipients, $message);