Hallo Attain,
vielen Dank für die Vorlage.
Ich wollte hier nur kurz meine Erweiterung um ein oder mehrere Bilder teilen.
PHP-Code:
<?php
$url = "https://outlook.office.com/webhook/40ded607-f14b-44d6-9236-4db84ef78f24@771c9c47-7f24-44dc-958e-34f8713a8394/IncomingWebhook/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/c73740f2-527f-4c13-9c81-2d61c3ea88b8";
$debug = false;
$Title = "Test";
$ThemeColor = "ff0000";
$Text = "Das ist nur ein Test <br> hallo ";
$Bilder = "https://BildUrl_1.jpg,https://BildUrl_2.jpg";
// Wenn mehrere Bilder dann in Array uebergeben
$ArrayBilder = explode(",", $Bilder);
// Json anfang
$json = '{';
// Werte übergeben
$json .= '"title":"'.$Title.'",';
$json .= '"themeColor":"'.$ThemeColor.'",';
$json .= '"text":"'.$Text.'"';
// Wenn Bild hinterlegt schleife durchgehen und bild einfügen
if(!empty($Bilder)) {
$pics = "";
for($i=0;$i<count($ArrayBilder);$i++) {
$pics .= '{"image":"'.$ArrayBilder[$i].'"},';
}
$json .= ',
"sections":[
{
"images":['.$pics.']
}
]';
}
// Json ende
$json .= '}';
$return = ATN_SendTeams($json,$url);
if ($debug) echo $return;
function ATN_SendTeams($payload,$url)
{
$handle = curl_init();
curl_setopt_array($handle,
array(
CURLOPT_URL => $url,
// Enable the post response.
CURLOPT_POST => true,
// The data to transfer with the response.
CURLOPT_HEADER => "Content-Type: application/json",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
)
);
$data = curl_exec($handle);
curl_close($handle);
return $data;
}