public function onAnnouncementCreated(ServiceEvent $event)
 {
     $announcement = $event->getSubject();
     if ($announcement['targetType'] == 'global') {
         $tuiClient = new EdusohoTuiClient();
         $result = $tuiClient->sendAnnouncement($announcement);
     }
 }
Example #2
0
 public function onUserFollowed(ServiceEvent $event)
 {
     $friend = $event->getSubject();
     $user = $this->getUserService()->getUser($friend['fromId']);
     $message = array('userId' => $user['id'], 'userName' => $user['nickname'], 'opration' => 'follow');
     $this->getNotificationService()->notify($friend['toId'], 'user-follow', $message);
     $message = array('fromId' => $friend['fromId'], 'toId' => $friend['toId'], 'type' => 'text', 'title' => '好友添加', 'content' => $user['nickname'] . '添加你为好友', 'custom' => json_encode(array('fromId' => $friend['fromId'], 'nickname' => $user['nickname'], 'typeBusiness' => 'verified')));
     $tuiClient = new EdusohoTuiClient();
     $result = $tuiClient->sendMessage($message);
 }
Example #3
0
 public function onMessageSended(ServiceEvent $event)
 {
     $message = $event->getSubject();
     $user = $this->getUserService()->getUser($message['fromId']);
     $largeAvatar = empty($user['largeAvatar']) ? '' : $this->getFileService()->parseFileUri($user['largeAvatar']);
     $message['title'] = $user['nickname'];
     $host = 'http://' . $_SERVER['HTTP_HOST'];
     $message['custom'] = json_encode(array('fromId' => $message['fromId'], 'nickname' => $user['nickname'], 'imgUrl' => empty($largeAvatar) ? $host . '/assets/img/default/avatar.png' : $host . '/files/' . $largeAvatar['path'], 'typeMsg' => $message['type'], 'typeBusiness' => in_array('ROLE_TEACHER', $user['roles']) ? 'teacher' : 'friend', 'createdTime' => time()));
     $tuiClient = new EdusohoTuiClient();
     $result = $tuiClient->sendMessage($message);
 }
Example #4
0
    return array('about' => isset($mobile['about']) ? $mobile['about'] : '');
});
/*
## 获取手机网校token
    GET /mobileschools/token

** 响应 **

```
{
    'token' => 'vPb16d4L9YFm9mqlvTyoCo0Y5og1vZL'
}
```
*/
$api->get('/token', function () {
    $tuiClient = new EdusohoTuiClient();
    $token = $tuiClient->getToken();
    if (isset($token['error'])) {
        throw new Exception($token['error']);
    }
    return $token;
});
/*
## 获取手机网校应用
    GET /mobileschools/apps

** 响应 **

```
{
    'id' => {app-id},