public function execute($params)
 {
     $smsType = 'sms_live_play_one_hour';
     $dayIsOpen = $this->getSmsService()->isOpen($smsType);
     $parameters = array();
     if ($dayIsOpen) {
         $targetType = $params['targetType'];
         $targetId = $params['targetId'];
         $processor = SmsProcessorFactory::create($targetType);
         $return = $processor->getUrls($targetId, $smsType);
         $callbackUrls = $return['urls'];
         $count = ceil($return['count'] / 1000);
         try {
             $api = CloudAPIFactory::create('leaf');
             $result = $api->post("/sms/sendBatch", array('total' => $count, 'callbackUrls' => $callbackUrls));
         } catch (\RuntimeException $e) {
             throw new \RuntimeException("发送失败!");
         }
     }
 }
 public function onCourseLessonPublish(ServiceEvent $event)
 {
     $lesson = $event->getSubject();
     if ($lesson['type'] == 'live') {
         $this->createJob($lesson);
         $smsType = 'sms_live_lesson_publish';
     } else {
         $smsType = 'sms_normal_lesson_publish';
     }
     if ($this->getSmsService()->isOpen($smsType)) {
         $processor = SmsProcessorFactory::create('lesson');
         $return = $processor->getUrls($lesson['id'], $smsType);
         $callbackUrls = $return['urls'];
         $count = ceil($return['count'] / 1000);
         try {
             $api = CloudAPIFactory::create('root');
             $result = $api->post("/sms/sendBatch", array('total' => $count, 'callbackUrls' => $callbackUrls));
         } catch (\RuntimeException $e) {
             throw new \RuntimeException("发送失败!");
         }
     }
 }
Example #3
0
 public function smsCallBackAction(Request $request, $targetType, $targetId)
 {
     $index = $request->query->get('index');
     $smsType = $request->query->get('smsType');
     $originSign = rawurldecode($request->query->get('sign'));
     $siteSetting = $this->getSettingService()->get('site');
     $siteSetting['url'] = rtrim($siteSetting['url']);
     $siteSetting['url'] = rtrim($siteSetting['url'], '/');
     $url = $siteSetting['url'];
     $url .= $this->generateUrl('edu_cloud_sms_send_callback', array('targetType' => $targetType, 'targetId' => $targetId));
     $url .= '?index=' . $index . '&smsType=' . $smsType;
     $api = CloudAPIFactory::create('leaf');
     $sign = $this->getSignEncoder()->encodeSign($url, $api->getAccessKey());
     if ($originSign != $sign) {
         return $this->createJsonResponse(array('error' => 'sign不正确'));
     }
     $processor = SmsProcessorFactory::create($targetType);
     return $this->createJsonResponse($processor->getSmsInfo($targetId, $index, $smsType));
 }