Files
afup/sources/AppBundle/Slack/LegacyClient.php
2019-05-25 13:07:12 +02:00

33 lines
829 B
PHP

<?php
namespace AppBundle\Slack;
class LegacyClient
{
private $token;
public function __construct($token)
{
$this->token = $token;
}
public function invite($email)
{
$return = file_get_contents(sprintf("https://slack.com/api/users.admin.invite?token=%s&email=%s", $this->token, $email));
if (false === $return) {
throw new \RuntimeException("Erreur lors de l'appel à l'API slack");
}
$decodedContent = json_decode($return, true);
if (false === $decodedContent) {
throw new \RuntimeException("Erreur lecture retour API slack");
}
if (false === $decodedContent["ok"]) {
throw new \RuntimeException(sprintf("Erreur sur le retour de l'appel slack : %s", $decodedContent['error']));
}
}
}