function deleteUser($gameName) { Util::throwExceptionIfNullOrBlank($gameName, "Game Name"); $encodedUserName = Util::encodeParams($gameName); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['gameName'] = $gameName; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/delete/" . $encodedUserName; $response = RestClient::delete($baseURL, $params, null, null, $contentType, $accept, $headerParams); $responseObj->setStrResponse($response->getResponse()); $responseObj->setResponseSuccess(true); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
function facebookLinkPostWithCustomThumbnail($accessToken, $link, $message, $pictureUrl, $name, $description) { Util::throwExceptionIfNullOrBlank($accessToken, "Access Token"); Util::throwExceptionIfNullOrBlank($link, "Link"); Util::throwExceptionIfNullOrBlank($message, "Message"); Util::throwExceptionIfNullOrBlank($pictureUrl, "PictureUrl"); Util::throwExceptionIfNullOrBlank($name, "File Name"); Util::throwExceptionIfNullOrBlank($description, "Description"); $objUtil = new Util($this->apiKey, $this->secretKey); $responseObj = new App42Response(); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $body = null; $body = '{"app42":{"social":{"link":"' . $link . '","accessToken":"' . $accessToken . '","message":"' . $message . '","picture":"' . $pictureUrl . '","name":"' . $name . '","description":"' . $description . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/facebook/publishstream"; $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $responseObj->setStrResponse($response->getResponse()); $responseObj->setResponseSuccess(true); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
/** * Add or Update preference list on the cloud. * * @param preferenceDataList * - List of PreferenceData which contains customerId, itemId, * preference * * @return App42Response object */ function addOrUpdatePreference($preferenceDataList) { Util::throwExceptionIfNullOrBlank($preferenceDataList, "Preference Data List"); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); $dataValue = array(); $preferenceData = new PreferenceData(); if (is_array($preferenceDataList)) { foreach ($preferenceDataList as $arrayValue) { $userId = $arrayValue->getUserId(); $itemId = $arrayValue->getItemId(); $preference = $arrayValue->getPreference(); $array = array("UserId" => $userId, "itemId" => $itemId, "preference" => $preference); array_push($dataValue, $array); } } else { $userId = $preferenceDataList->getUserId(); $itemId = $preferenceDataList->getItemId(); $preference = $preferenceDataList->getPreference(); $array = array("UserId" => $userId, "itemId" => $itemId, "preference" => $preference); array_push($dataValue, $array); } try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $body = null; //$body = '{"app42":{"preferences":{"preference":"' . $preferenceDataList->getUserId() . '","itemId":"' . $preferenceDataList->getItemId() . '","preference":"' . $preferenceDataList->getPreference() . '"}}}}'; $body = '{"app42":{"preferences":{"preference":' . json_encode($dataValue) . '}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/addOrUpdatePreference"; $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $responseObj->setStrResponse($response); $responseObj->setResponseSuccess(true); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
/** * Removes all the attributes for a given session id * * @param sessionId * - The session id for which the attributes has to be removed * * @return App42Response if removed successfully */ function removeAllAttributes($sessionId) { Util::throwExceptionIfNullOrBlank($sessionId, "session Id"); $encodedSessionId = Util::encodeParams($sessionId); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['sessionId'] = $sessionId; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/id/" . $encodedSessionId; $response = RestClient::delete($baseURL, $params, null, null, $contentType, $accept, $headerParams); $sessionResponseObj = new SessionResponseBuilder(); $sessionObj = $sessionResponseObj->buildResponse($response->getResponse()); $responseObj->setStrResponse($sessionObj); $responseObj->setResponseSuccess(true); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
/** * Gets the count of all the subscribed channels of a particular user. * @param $userName - Name of the user for which you want to get a count of the subscribed channels. * @return App42Response * @throws App42Exception */ function getUserSubscribedChannelsCount($userName) { Util::throwExceptionIfNullOrBlank($userName, "UserName"); $objUtil = new Util($this->apiKey, $this->secretKey); $pushObj = new App42Response(); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userName'] = $userName; $queryParams['userName'] = $userName; $params = array_merge($queryParams, $signParams); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/count/userchannels"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $pushObj->setStrResponse($response->getResponse()); $pushObj->setResponseSuccess(true); $pushResponseObj = new PushNotificationResponseBuilder(); $pushObj->setTotalRecords($pushResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $pushObj; }
/** * Delete the specified Geo points from Cloud. * * @param storageName * - Unique handler for storage name * * @return App42Response object containing the name of the storage that has * been deleted * * @throws App42Exception */ function deleteGeoPoints($geoStorageName, $geoPointsList) { Util::throwExceptionIfNullOrBlank($geoStorageName, "Geo Storage Name"); Util::throwExceptionIfNullOrBlank($geoPointsList, "Geo Points List"); $encodedStorageName = Util::encodeParams($geoStorageName); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); if (is_array($geoPointsList)) { $string = '{"app42":{ "geo": {"storage":{"points": { "point": ' . json_encode($geoPointsList) . '}}}}}'; } else { $string = '{"app42":{ "geo": {"storage":{"points": { "point": "' . $geoPointsList . '"}}}}}'; } $signParams['geoPoints'] = $string; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/points/" . $encodedStorageName; $response = RestClient::delete($baseURL, $params, null, null, $contentType, $accept, $headerParams); $geoResponseObj = new GeoResponseBuilder(); $geoObj = $geoResponseObj->buildResponse($response->getResponse()); $responseObj->setStrResponse($geoObj); $responseObj->setResponseSuccess(true); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
function getReviewsCountByItemAndRating($itemId, $rating) { Util::throwExceptionIfNullOrBlank($itemId, "Item Id"); Util::throwExceptionIfNullOrBlank($rating, "Rating"); $encodedItemId = Util::encodeParams($itemId); $encodedRating = Util::encodeParams($rating); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['itemId'] = $itemId; $signParams['rating'] = $rating; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/item" . "/" . $encodedItemId . "/rating" . "/" . $encodedRating; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $responseObj->setStrResponse($response->getResponse()); $responseObj->setResponseSuccess(true); $reviewResponseObj = new ReviewResponseBuilder(); $responseObj->setTotalRecords($reviewResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
function getCountByQuery($dbName, $collectionName, $query) { Util::throwExceptionIfNullOrBlank($dbName, "DataBase Name"); Util::throwExceptionIfNullOrBlank($collectionName, "Collection Name"); Util::throwExceptionIfNullOrBlank($query, "query"); $encodedDbName = Util::encodeParams($dbName); $encodedCollectionName = Util::encodeParams($collectionName); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); $queryObject = null; if ($query instanceof JSONObject) { $queryObject = array(); array_push($queryObject, $query); } else { $queryObject = $query; } try { $params = null; $storageObj = new App42Response(); $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['dbName'] = $dbName; $signParams['collectionName'] = $collectionName; $signParams['jsonQuery'] = json_encode($queryObject); $queryParams['jsonQuery'] = json_encode($queryObject); $params = array_merge($queryParams, $signParams); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/findDocsByQuery" . "/dbName/" . $encodedDbName . "/collectionName/" . $encodedCollectionName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $storageResponseObj = new StorageResponseBuilder(); $storageObj = $storageResponseObj->buildResponse($response->getResponse()); $totalRecord = $storageObj->getRecordCount(); $body = '{"app42":{"response":{"totalRecords":"' . $totalRecord . '"}}}'; $responseObj->setStrResponse($body); $responseObj->setResponseSuccess(true); $responseObj->setTotalRecords($totalRecord); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
function getActivityCountByUser($userId) { Util::throwExceptionIfNullOrBlank($userId, "UserId"); $encodedUserId = Util::encodeParams($userId); $objUtil = new Util($this->apiKey, $this->secretKey); $bravoObj = new App42Response(); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userId'] = $userId; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/activity/userId/" . $encodedUserId . "/count"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $bravoObj->setStrResponse($response->getResponse()); $bravoObj->setResponseSuccess(true); $bravoResponseObj = new BravoBoardResponseBuilder(); $bravoObj->setTotalRecords($bravoResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $bravoObj; }
/** * Fetches the count of all games for the App * * @return App42Response object containing count of all the Game for the App */ function getAllGamesCount() { $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $gameObj = new App42Response(); $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/count"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $gameObj->setStrResponse($response->getResponse()); $gameObj->setResponseSuccess(true); $gameResponseObj = new GameResponseBuilder(); $gameObj->setTotalRecords($gameResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $gameObj; }
function logout($sessionId) { Util::throwExceptionIfNullOrBlank($sessionId, "SessionId"); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $body = null; $body = '{"app42":{"session":{"id":"' . $sessionId . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->sessionURL . "/session"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $responseObj->setStrResponse($response->getResponse()); $responseObj->setResponseSuccess(true); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
/** * Fetch count of log messages based on Date range * * @param startDate * - Start date from which the count of log messages have to be * fetched * @param endDate * - End date upto which the count of log messages have to be * fetched * * @return App42Response object containing count of fetched messages */ function fetchLogCountByDateRange($startDate, $endDate) { Util::throwExceptionIfNullOrBlank($startDate, "Start Date"); Util::throwExceptionIfNullOrBlank($endDate, "End Date"); $validateStartDate = Util::validateDate($startDate); $validateEndDate = Util::validateDate($endDate); $encodedStartDate = Util::encodeParams($startDate); $encodedEndDate = Util::encodeParams($endDate); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $strStartDate = date("Y-m-d\\TG:i:s", strtotime($startDate)) . substr((string) microtime(), 1, 4) . "Z"; $strEndDate = date("Y-m-d\\TG:i:s", strtotime($endDate)) . substr((string) microtime(), 1, 4) . "Z"; $logObj = new App42Response(); $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['startDate'] = $strStartDate; $signParams['endDate'] = $strEndDate; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/startDate/" . $strStartDate . "/endDate/" . $strEndDate . "/count"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $logObj->setStrResponse($response->getResponse()); $logObj->setResponseSuccess(true); $logResponseObj = new LogResponseBuilder(); $logObj->setTotalRecords($logResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $logObj; }