public static function getDefaultDomainUrl($useSSL) { $urlStr = GTConfig::getProperty("gexin_default_domainurl", null); if ($urlStr == null || "" == trim($urlStr)) { if ($useSSL) { $hosts = array("https://cncapi.getui.com/serviceex", "https://telapi.getui.com/serviceex", "https://api.getui.com/serviceex", "https://sdk1api.getui.com/serviceex", "https://sdk2api.getui.com/serviceex", "https://sdk3api.getui.com/serviceex"); } else { $hosts = array("http://sdk.open.api.igexin.com/serviceex", "http://sdk.open.api.gepush.com/serviceex", "http://sdk.open.api.getui.net/serviceex", "http://sdk1.open.api.igexin.com/serviceex", "http://sdk2.open.api.igexin.com/serviceex", "http://sdk3.open.api.igexin.com/serviceex"); } } else { $list = explode(",", $urlStr); $hosts = array(); foreach ($list as $value) { if (strpos($value, "https://") === 0 && !$useSSL) { continue; } if (strpos($value, "http://") === 0 && $useSSL) { continue; } if ($useSSL && strpos($value, "http") != 0) { $value = "https://" . $value; } array_push($hosts, $value); } } return $hosts; }
public static function getDefaultDomainUrl() { $urlStr = GTConfig::getProperty("gexin_default_domainurl", null); if ($urlStr == null || "" . equals(trim($urlStr))) { $hosts = array("http://sdk.open.api.igexin.com/serviceex", "http://sdk.open.api.gepush.com/serviceex", "http://sdk.open.api.getui.net/serviceex"); for ($i = 0; $i < 3; $i++) { array_push($hosts, "http://sdk" . $i . ".open.api.igexin.com/serviceex"); } return $hosts; } return explode(",", $urlStr); }
/** * @param $url * @param array $params * @param $gzip * @return mixed|null * @throws RequestException */ public static function httpPostJson($url, $params = [], $gzip = false) { if (!array_key_exists('version', $params)) { $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 static function httpPostJson($url, $params, $gzip) { if (is_null($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"; $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); }
/** * 根据deviceTokenList群推 * @param $appId * @param $contentId * @param $deviceTokenList * @return mixed * @throws RequestException * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ public function pushAPNMessageToList($appId, $contentId, $deviceTokenList) { $params = array(); $params['action'] = 'apnPushToListAction'; $params['appkey'] = $this->appkey; $params['appId'] = $appId; $params['contentId'] = $contentId; $params['DTL'] = $deviceTokenList; $needDetails = GTConfig::isPushListNeedDetails(); $params['needDetails'] = $needDetails; return $this->httpPostJSON($this->host, $params); }
/** * 根据deviceTokenList群推 * @param $appId * @param $contentId * @param $deviceTokenList * @return mixed */ public function pushAPNMessageToList($appId, $contentId, $deviceTokenList) { $params = array(); $params["action"] = "apnPushToListAction"; $params["appkey"] = $this->appkey; $params["appId"] = $appId; $params["contentId"] = $contentId; $params["DTL"] = $deviceTokenList; $needDetails = GTConfig::isPushListNeedDetails(); $params["needDetails"] = $needDetails; return $this->httpPostJSON($this->host, $params); }
/** * @return array */ public static function getDefaultDomainUrl() { $urlStr = GTConfig::getProperty('gexin_default_domainurl', null); if ($urlStr === null || '' === trim($urlStr)) { $hosts = array('http://sdk.open.api.igexin.com/serviceex', 'http://sdk.open.api.gepush.com/serviceex', 'http://sdk.open.api.getui.net/serviceex'); for ($i = 0; $i < 3; $i++) { $hosts[] = 'http://sdk' . $i . '.open.api.igexin.com/serviceex'; } return $hosts; } return explode(',', $urlStr); }
/** * @return mixed * @throws RequestException */ public function submit() { $requestId = uniqid('', true); $data = array(); $data['appkey'] = $this->APPKEY; $data['serialize'] = 'pb'; $data['async'] = GTConfig::isPushSingleBatchAsync(); $data['action'] = 'pushMessageToSingleBatchAction'; $data['requestId'] = $requestId; $singleBatchRequest = new SingleBatchRequest(); $singleBatchRequest->setBatchId($this->batchId); foreach ($this->innerMsgList as $index => $innerMsg) { $singleBatchRequest->addBatchItem(); $singleBatchRequest->setBatchItem($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; }