Example #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->getClientId();
         $targetAlias = $target->getAlias();
         if ($targetCid != null) {
             array_push($clientIdList, $targetCid);
         } elseif ($targetAlias != null) {
             array_push($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);
 }