public function sendHttpGet(HttpGet $get = null) { $this->_options = array(); $this->_options[CURLOPT_HTTPGET] = true; $this->_options[CURLOPT_POST] = false; $this->_options[CURLOPT_PUT] = false; $url = $this->_url; if ($get != null && $get->getQueryParameters() != null) { $url = $this->_url . '?' . $get->getQueryParameters(); } return $this->_sendRequest($url); }
/** * Sends a request to the API for getting an advertisement. * * @param string $category category of this app. * @param string $userAgent user agent string to send to API. * @param string $udid specifies a universially unique * identifier, which must be at least 30 * characters in length. * @param OptArgs|null $optArgs any optional values. * * @return null|ADSResponse null if no ads were returned, * otherwise an ADSResponse object * @throws ServiceException if API request was not successful */ public function getAdvertisement($category, $userAgent, $udid, OptArgs $optArgs = null, $raw_response = false) { $endpoint = $this->getFqdn() . '/rest/1/ads'; $req = new RestfulRequest($endpoint); $req->setAuthorizationHeader($this->getToken())->setHeader('User-agent', $userAgent)->setHeader('Udid', $udid); $httpGet = new HttpGet(); $httpGet->setParam('Category', $category); if ($optArgs != null) { $this->_appendOptArgs($httpGet, $optArgs); } $result = $req->sendHttpGet($httpGet); // no ads returned if ($result->getResponseCode() == 204) { if ($raw_response) { return $result->getResponseBody(); } return null; } if ($raw_response) { return Service::parseApiResposeBody($result); } // response as json array $jarr = Service::parseJson($result); return ADSResponse::fromArray($jarr); }
public function getNotificationConnectionDetails($queues) { $endpoint = $this->getFqdn() . '/myMessages/v2/notificationConnectionDetails'; $req = new RestfulRequest($endpoint); $req->setHeader('Accept', 'application/json')->setAuthorizationHeader($this->getToken()); $httpGet = new HttpGet(); $httpGet->setParam('queues', $queues); $result = $req->sendHttpGet($httpGet); $arr = Service::parseJson($result); return IMMNNotificactionCD::fromArray($arr); }
/** * Sends a request to the API gateway for getting contacts owned by a group. * * @param string $groupId group id * @param PaginationParameters $params paginiation params * * @return array contact ids * @throws ServiceException if request was not successful */ public function getGroupContacts($groupId, PaginationParameters $params = null) { $groupId = urlencode($groupId); $subUrl = "/addressBook/v1/groups/{$groupId}/contacts"; $endpoint = $this->getFqdn() . $subUrl; $req = new RESTFulRequest($endpoint); $req->setAuthorizationHeader($this->getToken())->setHeader('Accept', 'application/json'); $httpGet = new HttpGet(); if ($params != null) { $httpGet->setParams($params->toArray()); } $result = $req->sendHttpGet($httpGet); $successCodes = array(200); $arr = Service::parseJson($result, $successCodes); $contactName = $arr['contactIds']; $contactArr = $contactName['id']; return $contactArr; }