Closed kevshah1 closed 4 years ago
@kevshah1 How did you include the package in you project? Is the TeamsConnector.php located in vendor\sebbmeyer\php-microsoft-teams-connector\src
?
Hi Done the below: require 'vendor\sebbmeyer\php-microsoft-teams-connector\src\TeamsConnector.php'; require 'vendor\sebbmeyer\php-microsoft-teams-connector\src\AbstractCard.php'; require 'vendor\sebbmeyer\php-microsoft-teams-connector\src\Cards\SimpleCard.php'; require 'vendor\sebbmeyer\php-microsoft-teams-connector\src\Cards\CustomCard.php';
and
use Sebbmyr\Teams\TeamsConnector; use Sebbmyr\Teams\SimpleCard; use Sebbmyr\Teams\TeamsConnectorInterface;
TeamsConnector.php is located in the correct folder
You are trying to include it in a plain php script, correct? If yes, you don't need use. So the following should work:
require_once 'vendor/autoload.php';
$connector = new TeamsConnector('<WEBHOOK_URL>');
$card = new SimpleCard(['title' => 'Simple Card', 'text' => 'Hello World']);
$connector->send($card);
I used the answer from here and modified it, but I didn't test it
Changed as per your suggestion but now getting a Fatal error: Uncaught Error: Class 'TeamsConnector' not found.
Yes, using a plain PHP script.
Ok, I tried it and this worked for me:
<?php
require __DIR__ . '/vendor/autoload.php';
$connector = new Sebbmyr\Teams\TeamsConnector('<WEBHOOK_URL>');
// create card
$card = new Sebbmyr\Teams\Cards\SimpleCard(['title' => 'Simple card title', 'text' => 'Simple card text']);
// send card via connector
$connector->send($card);
Thank you so much works now!
Useful for anyone that may be using it with plain PHP.
Following the simple card example, getting Fatal error: Uncaught Error: Class 'Sebbmyr\Teams\TeamsConnector' not found
Have also tried to include the teams connector by doing 'use Sebbmyr\Teams\TeamsConnector;' however still does not work.
Environment uses PHP v7.4.