public static function httpPostJson($url, $params, $gzip) { if (!isset($params["version"])) { $params["version"] = GTConfig::getSDKVersion(); } $action = $params["action"]; $data = json_encode($params); $result = null; try { $resp = HttpManager::httpPost($url, $data, $gzip, $action); //LogUtils::debug("发送请求 post:{$data} return:{$resp}"); $result = json_decode($resp, true); return $result; } catch (\Exception $e) { throw new RequestException($params["requestId"], "httpPost:[" . $url . "] [" . $data . " ] [ " . $result . "]:", $e); } }
public function submit() { $requestId = uniqid(); $data = array(); $data["appkey"] = $this->APPKEY; $data["serialize"] = "pb"; $data["async"] = GTConfig::isPushSingleBatchAsync(); $data["action"] = "pushMessageToSingleBatchAction"; $data['requestId'] = $requestId; $singleBatchRequest = new SingleBatchRequest(); $singleBatchRequest->set_batchId($this->batchId); foreach ($this->innerMsgList as $index => $innerMsg) { $singleBatchRequest->add_batchItem(); $singleBatchRequest->set_batchItem($index, $innerMsg); } $data["singleDatas"] = base64_encode($singleBatchRequest->SerializeToString()); $this->seqId = 0; $this->innerMsgList = array(); $this->lastPostData = $data; $result = $this->push->httpPostJSON(null, $data, true); return $result; }
public function getUserCountByTags($appId, $tagList) { $params = array(); $params["action"] = "getUserCountByTags"; $params["appkey"] = $this->appkey; $params["appId"] = $appId; $params["tagList"] = $tagList; $limit = GTConfig::getTagListLimit(); if (count($tagList) > $limit) { throw new \Exception("tagList size:" . count($tagList) . " beyond the limit:" . $limit); } return $this->httpPostJSON($this->host, $params); }