Created
August 26, 2021 14:41
-
-
Save vgrovestine/1949c22996998f7368d34a596ab0a8a4 to your computer and use it in GitHub Desktop.
Simple utility to chat directly with a person via Microsoft Teams given their email address, without need to manually search for that particular individual in the application.
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 | |
// Usage: | |
// https://mysite.xyz/chatwith.php?person=ME@MYSITE.XYZ | |
// | |
// Logging: | |
// Saved as ../chatwith_log/YYYY-MM.csv | |
// Write permissions required for web server. | |
// | |
// Reference: | |
// https://www.msoutlook.info/question/teams-chat-link-in-email-signature | |
// https://teams.microsoft.com/l/chat/0/0?users=<youremailaddress> | |
function isValidEmail($email) { | |
if(preg_match('/^[a-z0-9._%+-]+@(MYSITE\.XYZ)$/i', $email)) { | |
// ** | |
// ** IMPORTANT: Change "MYSITE\.XYZ", above, to your own email domain. | |
// ** | |
return true; | |
} | |
return false; | |
} | |
$person = (array_key_exists('person', $_GET) ? trim(urldecode($_GET['person'])) : false); | |
$loginfo = array( | |
date('Y-m-d H:i:s'), | |
$person, | |
$_SERVER['HTTP_HOST'], | |
$_SERVER['REQUEST_URI'], | |
$_SERVER['HTTP_REFERER'], | |
$_SERVER['REMOTE_ADDR'], | |
$_SERVER['HTTP_USER_AGENT'] | |
); | |
$fp = fopen('../chatwith_log/' . date('Y-m') . '.csv', 'a'); | |
fputcsv($fp, $loginfo); | |
fclose($fp); | |
if(!isValidEmail($person)) { | |
die('Usage: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?person=<firstname.lastname@acadiau.ca>'); | |
} | |
header('Location: https://teams.microsoft.com/l/chat/0/0?users=' . $person); | |
exit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment