1. Go to this page and download the library: Download shahil/msgraph library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Shahil\MSGraph\Facades\MSGraph;
$userId = MSGraph::getUserId('[email protected]');
use Shahil\MSGraph\Facades\MSGraph;
MSGraph::sendMessageToUser('[email protected]', 'Hello from Laravel!');
use Shahil\MSGraph\Facades\MSGraph;
// Retrieve the group chat ID by its name
$chatId = MSGraph::getChatIdByGroupName('Your Group Name');
// Send a message to the group
MSGraph::sendMessageToGroup($chatId, 'Hello group members!');
use Shahil\MSGraph\Facades\MSGraph;
$chatId = MSGraph::getChatIdByGroupName('Your Group Name');
use Shahil\MSGraph\Facades\MSGraph;
$targetUserId = MSGraph::getUserId('[email protected]');
$chatId = MSGraph::getChatId($targetUserId);
namespace App\Http\Controllers;
use Shahil\MSGraph\Facades\MSGraph;
class TeamsController extends Controller
{
public function sendGroupMessage()
{
try {
$chatId = MSGraph::getChatIdByGroupName('Your Group Name');
MSGraph::sendMessageToGroup($chatId, 'Hello, team!');
return response()->json(['success' => 'Message sent to the group successfully.']);
} catch (\Exception $e) {
return response()->json(['error' => $e->getMessage()]);
}
}
}