本文整理汇总了PHP中Util::sign方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::sign方法的具体用法?PHP Util::sign怎么用?PHP Util::sign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util
的用法示例。
在下文中一共展示了Util::sign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createApp
function createApp($appName, $orgName)
{
Util::throwExceptionIfNullOrBlank($appName, "App Name");
Util::throwExceptionIfNullOrBlank($orgName, "orgName");
$objUtil = new Util($this->apiKey, $this->secretKey);
try {
$params = array();
$params['apiKey'] = $this->apiKey;
$params['version'] = $this->version;
date_default_timezone_set('UTC');
$params['timeStamp'] = date("Y-m-d\\TG:i:s") . substr((string) microtime(), 1, 4) . "Z";
$params['App Name'] = $appName;
$params['orgName'] = $orgName;
$signature = urlencode($objUtil->sign($params));
//die();
$body = null;
$body = '{"app42":{"app":}}';
$params['body'] = $body;
$params['signature'] = $signature;
$contentType = $this->content_type;
$accept = $this->accept;
$this->url = $this->url;
$response = RestClient::post($this->url, $params, null, null, $contentType, $accept, $body);
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $response;
}
示例2: isActive
function isActive($testName)
{
Util::throwExceptionIfNullOrBlank($testName, "testName");
$objUtil = new Util($this->apiKey, $this->secretKey);
try {
$params = null;
$headerParams = array();
$queryParams = array();
$signParams = $this->populateSignParams();
$metaHeaders = $this->populateMetaHeaderParams();
$signParams['testName'] = $testName;
$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 . "/isActive/" . $testName;
$response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
$abTestRespObj = new ABTestResponseBuilder();
$abTestObj = $abTestRespObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $abTestObj;
}
示例3: getCountByQuery
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;
}
示例4: deleteGeoPoints
/**
* 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;
}
示例5: addOrUpdatePreference
/**
* 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;
}
示例6: gocoin_callback
function gocoin_callback()
{
global $woocommerce;
$gateways = $woocommerce->payment_gateways->payment_gateways();
$logger = new WC_Logger();
if (!isset($gateways['gocoin'])) {
return;
}
$gocoin = $gateways['gocoin'];
$gocoin_setting = isset($gocoin->settings) && is_array($gocoin->settings) ? $gocoin->settings : array();
$key = isset($gocoin_setting['accessToken']) && !empty($gocoin_setting['accessToken']) ? $gocoin_setting['accessToken'] : '';
if (empty($key)) {
return $logger->add('gocoin-callback', 'Api Key is blank');
}
$data = Util::postData();
if (isset($data->error)) {
return $logger->add('gocoin-callback', $data->error);
} else {
// $key = $gocoin -> settings -> accessToken;
$event_id = $data->id;
$event = $data->event;
$invoice = $data->payload;
$payload_arr = get_object_vars($invoice);
ksort($payload_arr);
$signature = $invoice->user_defined_8;
$sig_comp = Util::sign($payload_arr, $key);
$status = $invoice->status;
$order_id = (int) $invoice->order_id;
$order = WC_Order_Factory::get_order($order_id);
if (!$order) {
$msg = "Order with id: " . $order_id . " was not found. Event ID: " . $event_id;
return $logger->add('gocoin-callback', $msg);
}
// Check that if a signature exists, it is valid
if (isset($signature) && $signature != $sig_comp) {
$msg = "Signature : " . $signature . "does not match for Order: " . $order_id . "{$sig_comp} | {$signature} ";
} elseif (empty($signature) || empty($sig_comp)) {
$msg = "Signature is blank for Order: " . $order_id;
} elseif ($signature == $sig_comp) {
switch ($event) {
case 'invoice_created':
break;
case 'invoice_payment_received':
switch ($status) {
case 'ready_to_ship':
$msg = 'Order ' . $order_id . ' is paid and awaiting payment confirmation on blockchain.';
$order->update_status('on-hold', __($msg, 'woothemes'));
break;
case 'paid':
$msg = 'Order ' . $order_id . ' is paid and awaiting payment confirmation on blockchain.';
$order->update_status('on-hold', __($msg, 'woothemes'));
break;
case 'underpaid':
$msg = 'Order ' . $order_id . ' is underpaid.';
$order->update_status('on-hold', __($msg, 'woothemes'));
break;
}
break;
case 'invoice_merchant_review':
$msg = 'Order ' . $order_id . ' is under review. Action must be taken from the GoCoin Dashboard.';
$order->update_status('on-hold', __($msg, 'woothemes'));
break;
case 'invoice_ready_to_ship':
$msg = 'Order ' . $order_id . ' has been paid in full and confirmed on the blockchain.';
$order->payment_complete();
break;
case 'invoice_invalid':
$msg = 'Order ' . $order_id . ' is invalid and will not be confirmed on the blockchain.';
$order->update_status('failed', __($msg, 'woothemes'));
break;
default:
$msg = "Unrecognized event type: " . $event;
}
if (isset($msg)) {
$msg .= ' Event ID: ' . $event_id;
}
}
return $logger->add('gocoin-callback', $msg);
}
}
示例7: updatePhoto
function updatePhoto($userName, $albumName, $photoName, $photoDescription, $path)
{
Util::throwExceptionIfNullOrBlank($userName, "User Name");
Util::throwExceptionIfNullOrBlank($albumName, "Album Name");
Util::throwExceptionIfNullOrBlank($photoName, "Photo Name");
Util::throwExceptionIfNullOrBlank($photoDescription, "Description");
Util::throwExceptionIfNullOrBlank($path, "Path");
Util::throwExceptionIfNotValidImageExtension($path, "Photo Path");
$encodedUserName = Util::encodeParams($userName);
$objUtil = new Util($this->apiKey, $this->secretKey);
if (!file_exists($path)) {
throw new App42Exception("File Not Found");
}
try {
$params = null;
$headerParams = array();
$queryParams = array();
$signParams = $this->populateSignParams();
$metaHeaders = $this->populateMetaHeaderParams();
$headerParams = array_merge($signParams, $metaHeaders);
$postParams = array();
$postParams['userName'] = $userName;
$postParams['albumName'] = $albumName;
$postParams['name'] = $photoName;
$postParams['description'] = $photoDescription;
$params = array_merge($postParams, $signParams);
$signature = urlencode($objUtil->sign($params));
//die();
$params['imageFile'] = "@" . $path;
$headerParams['signature'] = $signature;
$contentType = "multipart/form-data";
$body = null;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL . "/update/" . $encodedUserName;
$response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
$photoResponseObj = new AlbumResponseBuilder();
$photoObj = $photoResponseObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $photoObj;
}
示例8: getFacebookProfilesFromIds
function getFacebookProfilesFromIds($facebookIds)
{
Util::throwExceptionIfNullOrBlank($facebookIds, "FacebookIds");
$objUtil = new Util($this->apiKey, $this->secretKey);
$body = null;
try {
$params = null;
$headerParams = array();
$queryParams = array();
$signParams = $this->populateSignParams();
$metaHeaders = $this->populateMetaHeaderParams();
$headerParams = array_merge($signParams, $metaHeaders);
if (is_array($facebookIds)) {
$headerParams['userList'] = json_encode($facebookIds);
} else {
$headerParams['userList'] = $facebookIds;
}
$signature = urlencode($objUtil->sign($signParams));
//die();
$headerParams['signature'] = $signature;
$contentType = $this->content_type;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL . "/facebook/ids";
$response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
$socialResponseObj = new SocialResponseBuilder();
$socialObj = $socialResponseObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $socialObj;
}
示例9: sendMail
/**
* This Service is used to send Emails. This service can be used by app to send mail to one or multiple recipients.
*
* @params sendTo
* - The email ids to which the email has to be sent. Email can
* be sent to multiple email ids. Multiple email ids can be
* passed using comma as the separator e.g. sid@shephertz.com,
* info@shephertz.com
* @params sendSubject
* - Subject of the Email which to be sent
* @params sendMsg
* - Email body which has to be sent
* @params fromEmail
* - The Email Id using which the mail(s) has to be sent
* @params emailMime
* - MIME Type to be used for sending mail. EmailMIME available
* options are PLAIN_TEXT_MIME_TYPE or HTML_TEXT_MIME_TYPE
*
* @return Email object containing all the details used for sending mail
*/
function sendMail($fromEmail, $sendTo, $sendSubject, $sendMsg, $emailMIME)
{
Util::throwExceptionIfNullOrBlank($fromEmail, "Email Id");
Util::throwExceptionIfNullOrBlank($sendTo, "Send To");
Util::throwExceptionIfNullOrBlank($sendSubject, "Send Subject");
Util::throwExceptionIfNullOrBlank($sendMsg, "Send Message");
Util::throwExceptionIfNullOrBlank($emailMIME, "EmailMIME");
$objUtil = new Util($this->apiKey, $this->secretKey);
try {
$params = null;
$emailMIMETypeObj = new EmailMIME();
if ($emailMIMETypeObj->isAvailable($emailMIME) == "null") {
throw new App42Exception("The EmailMIME with type '{$emailMIME}' does not Exist ");
}
$headerParams = array();
$queryParams = array();
$signParams = $this->populateSignParams();
$metaHeaders = $this->populateMetaHeaderParams();
$headerParams = array_merge($signParams, $metaHeaders);
$body = null;
$body = '{"app42":{"email":{"emailId":"' . $fromEmail . '","to":"' . $sendTo . '","subject":"' . $sendSubject . '","msg":"' . $sendMsg . '","mimeType":"' . $emailMIME . '"}}}';
$signParams['body'] = $body;
$signature = urlencode($objUtil->sign($signParams));
//die();
$headerParams['signature'] = $signature;
$contentType = $this->content_type;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL;
$response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
$emailResponseObj = new EmailResponseBuilder();
$emailObj = $emailResponseObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $emailObj;
}
示例10: getUsersWithScoreRange
function getUsersWithScoreRange($gameName, $minScore, $maxScore)
{
Util::throwExceptionIfNullOrBlank($gameName, "Game Name");
$encodedGameName = Util::encodeParams($gameName);
$encodedMinScore = Util::encodeParams($minScore);
$encodedMaxScore = Util::encodeParams($maxScore);
$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['name'] = $gameName;
$signParams['minScore'] = $minScore;
$signParams['maxScore'] = $maxScore;
$signature = urlencode($objUtil->sign($signParams));
//die();
$headerParams['signature'] = $signature;
$contentType = $this->content_type;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL . "/" . $encodedGameName . "/range/" . $minScore . "/" . $maxScore;
$response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
$gameResponseObj = new GameResponseBuilder();
$gameObj = $gameResponseObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $gameObj;
}
示例11: convertFormat
/**
* Converts the format of the image. Returns the original image url and converted image url.
* Images are stored on the cloud and can be accessed through the urls
* Conversion is done based on the formatToConvert provided
*
* @param name
* - Name of the image to convert
* @param imagePath
* - Path of the local file to convert
* @param formatToConvert
* - To which file needs to be converted
* @return Image object containing urls for the original and converted
* images
*
* @throws App42Exception
*
*/
function convertFormat($name, $imagePath, $formatToConvert)
{
Util::throwExceptionIfNullOrBlank($name, "Name");
Util::throwExceptionIfNullOrBlank($imagePath, "Image Path");
Util::throwExceptionIfNotValidImageExtension($imagePath, "imagePath");
Util::throwExceptionIfNullOrBlank($formatToConvert, "formatToConvert");
$objUtil = new Util($this->apiKey, $this->secretKey);
//$file = fopen($filePath, r);
if (!file_exists($imagePath)) {
throw new App42Exception(" File " . $imagePath . " does not exist");
}
//$file = new File($filePath);
//if(!file_exists($file)){
//throw Exception
//}
try {
$params = null;
$headerParams = array();
$queryParams = array();
$signParams = $this->populateSignParams();
$metaHeaders = $this->populateMetaHeaderParams();
$headerParams = array_merge($signParams, $metaHeaders);
$postParams = array();
$postParams['name'] = $name;
$postParams['formatToConvert'] = $formatToConvert;
$params = array_merge($postParams, $signParams);
$signature = urlencode($objUtil->sign($params));
//die();
$params['imageFile'] = "@" . $imagePath;
$headerParams['signature'] = $signature;
//CONTENT_TYPE == "multipart/form-data"
$contentType = "multipart/form-data";
$body = null;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL . "/convertformat";
$response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
$imageResponseObj = new ImageProcessorResponseBuilder();
$imageObj = $imageResponseObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $imageObj;
}
示例12: process_payment
/**
* Process payment for woocommerce checkout
*
* @param mixed $order_id
*/
function process_payment($order_id)
{
global $woocommerce, $wpdb;
$access_token = $this->settings['accessToken'];
$merchant_id = $this->settings['merchantId'];
$logger = new WC_Logger();
// Check to make sure we have an access token (API Key)
if (empty($access_token)) {
$msg = 'Improper Gateway set up. Access token not found.';
$logger->add('gocoin', $msg);
$woocommerce->add_error(__($msg));
} elseif (empty($merchant_id)) {
$msg = 'Improper Gateway set up. Merchant ID not found.';
$logger->add('gocoin', $msg);
$woocommerce->add_error(__($msg));
} else {
// Build the WooCommerce order, is has status "Pending"
$order = new WC_Order($order_id);
// Handle breaking route changes for after-purchase pages
if (version_compare(WOOCOMMERCE_VERSION, '2.1.0', '>=')) {
$redirect_url = $this->get_return_url($this->order);
} else {
$redirect_url = add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id'))));
}
$callback_url = plugin_dir_url(__FILE__) . 'gocoin-callback.php';
$currency = get_woocommerce_currency();
$options = array("type" => 'bill', "base_price" => $order->order_total, "base_price_currency" => $currency, "callback_url" => $callback_url, "redirect_url" => $redirect_url, "order_id" => $order_id, "customer_name" => $order->shipping_first_name . ' ' . $order->shipping_last_name, "customer_address_1" => $order->shipping_address_1, "customer_address_2" => $order->shipping_address_2, "customer_city" => $order->shipping_city, "customer_region" => $order->shipping_state, "customer_postal_code" => $order->shipping_postcode, "customer_country" => $order->shipping_country, "customer_phone" => $order->shipping_phone, "customer_email" => $order->shipping_email);
// Sign invoice with access token, if this fails we should still allow user to check out.
if ($signature = Util::sign($options, $access_token)) {
$options['user_defined_8'] = $signature;
}
try {
$invoice = GoCoin::createInvoice($access_token, $merchant_id, $options);
$url = $invoice->gateway_url;
$woocommerce->cart->empty_cart();
return array('result' => 'success', 'redirect' => $url);
} catch (Exception $e) {
$msg = $e->getMessage();
$order->add_order_note(var_export($msg));
$logger->add('gocoin', $msg);
$woocommerce->add_error(__($msg));
}
}
}
示例13: getUsersByGroup
function getUsersByGroup($users)
{
$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);
$signature = urlencode($objUtil->sign($signParams));
//die();
$headerParams['signature'] = $signature;
if (is_array($users)) {
$headerParams['userList'] = json_encode($users);
} else {
$headerParams['userList'] = $users;
}
$contentType = $this->content_type;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL . "/groupusers";
$response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
$userResponseObj = new UserResponseBuilder();
$userObj = $userResponseObj->buildArrayResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $userObj;
}
示例14: removeAllAttributes
/**
* 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;
}
示例15: deductScore
/**
* Deducts the score from users account for a particular Game
*
* @param gameName
* - Name of the game for which scores have to be deducted
* @param gameUserName
* - The user for whom scores have to be deducted
* @param gameScore
* - The scores that have to be deducted
*
* @return Game object containing the scores that has been deducted
*/
function deductScore($gameName, $gameUserName, $gameScore)
{
Util::throwExceptionIfNullOrBlank($gameName, "Game Name");
Util::throwExceptionIfNullOrBlank($gameUserName, "User Name");
Util::throwExceptionIfNullOrBlank($gameScore, "Score");
$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":{"game":{"name":"' . $gameName . '", "scores":{"score":{"userName":"' . $gameUserName . '","value":"' . $gameScore . '"}}}}}';
$signParams['body'] = $body;
$signature = urlencode($objUtil->sign($signParams));
//die();
$headerParams['signature'] = $signature;
$contentType = $this->content_type;
$accept = $this->accept;
$baseURL = $this->url;
$baseURL = $baseURL . "/deduct";
$response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
$gameResponseObj = new GameResponseBuilder();
$gameObj = $gameResponseObj->buildResponse($response->getResponse());
} catch (App42Exception $e) {
throw $e;
} catch (Exception $e) {
throw new App42Exception($e);
}
return $gameObj;
}