Esempio n. 1
0
 /**
  *  批量推送信息
  * @param  String contentId
  * @param  Array <IGtTarget> targetList
  * @return Array {result:successed_offline,taskId:xxx}  || {result:successed_online,taskId:xxx} || {result:error}
  ***/
 public function pushMessageToList($contentId, $targetList)
 {
     $params = array();
     $params["action"] = "pushMessageToListAction";
     $params["appkey"] = $this->appkey;
     $params["contentId"] = $contentId;
     $needDetails = GTConfig::isPushListNeedDetails();
     $params["needDetails"] = $needDetails;
     $async = GTConfig::isPushListAsync();
     $params["async"] = $async;
     if ($async && !$needDetails) {
         $limit = GTConfig::getAsyncListLimit();
     } else {
         $limit = GTConfig::getSyncListLimit();
     }
     if (count($targetList) > $limit) {
         throw new Exception("target size:" . count($targetList) . " beyond the limit:" . $limit);
     }
     $clientIdList = array();
     $aliasList = array();
     $appId = null;
     foreach ($targetList as $target) {
         $targetCid = $target->get_clientId();
         $targetAlias = $target->get_alias();
         if ($targetCid != null) {
             array_push($clientIdList, $targetCid);
         } elseif ($targetAlias != null) {
             array_push($aliasList, $targetAlias);
         }
         if ($appId == null) {
             $appId = $target->get_appId();
         }
     }
     $params["appId"] = $appId;
     $params["clientIdList"] = $clientIdList;
     $params["aliasList"] = $aliasList;
     $params["type"] = 2;
     return $this->httpPostJSON($this->host, $params, true);
 }
Esempio n. 2
0
 /**
  *  批量推送信息
  * @param  String $contentId
  * @param  Array <IGtTarget> targetList
  * @return Array {result:successed_offline,taskId:xxx}  || {result:successed_online,taskId:xxx} || {result:error}
  * @throws \Exception
  ***/
 public function pushMessageToList($contentId, $targetList)
 {
     $params = array();
     $params['action'] = 'pushMessageToListAction';
     $params['appkey'] = $this->appkey;
     $params['contentId'] = $contentId;
     $needDetails = GTConfig::isPushListNeedDetails();
     $params['needDetails'] = $needDetails;
     $async = GTConfig::isPushListAsync();
     $params['async'] = $async;
     if ($async && !$needDetails) {
         $limit = GTConfig::getAsyncListLimit();
     } else {
         $limit = GTConfig::getSyncListLimit();
     }
     if (count($targetList) > $limit) {
         throw new \InvalidArgumentException('target size:' . count($targetList) . ' beyond the limit:' . $limit);
     }
     $clientIdList = array();
     $aliasList = array();
     $appId = null;
     foreach ($targetList as $target) {
         $targetCid = $target->getClientId();
         $targetAlias = $target->getAlias();
         if ($targetCid !== null) {
             $clientIdList[] = $targetCid;
         } elseif ($targetAlias !== null) {
             $aliasList[] = $targetAlias;
         }
         if ($appId === null) {
             $appId = $target->getAppId();
         }
     }
     $params['appId'] = $appId;
     $params['clientIdList'] = $clientIdList;
     $params['aliasList'] = $aliasList;
     $params['type'] = 2;
     return $this->httpPostJSON($this->host, $params, true);
 }