post() public méthode

public post ( $url, $parameters = [], $headers = [] )
Exemple #1
0
 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;
 }
 /**
  * Creates a game on the cloud
  *
  * @param gameName
  *            - Name of the game that has to be created
  * @param gameDescription
  *            - Description of the game to be created
  *
  * @return Game object containing the game which has been created
  */
 function createGame($gameName, $gameDescription)
 {
     Util::throwExceptionIfNullOrBlank($gameName, "Game Name");
     Util::throwExceptionIfNullOrBlank($gameDescription, "Game Description");
     $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 . '","description":"' . $gameDescription . '"}}}';
         $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);
         $gameResponseObj = new GameResponseBuilder();
         $gameObj = $gameResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $gameObj;
 }
Exemple #3
0
 public function test_json_post()
 {
     global $TEST_SERVER_URL;
     $api = new RestClient();
     $result = $api->post($TEST_SERVER_URL, "{\"foo\":\"bar\"}", array('Content-Type' => 'application/json'));
     $response_json = $result->decode_response();
     $this->assertEquals('application/json', $response_json->headers->{"Content-Type"});
     $this->assertEquals('POST', $response_json->SERVER->REQUEST_METHOD);
     $this->assertEquals("{\"foo\":\"bar\"}", $response_json->body);
 }
Exemple #4
0
function get_aaa()
{
    $options = ['decoders' => array('json' => 'decode_result_as_json', 'php' => 'unserialize')];
    $api = new RestClient($options);
    $result = $api->post("https://api.naa.gov.au/naa/api/v1/person/search-series-b2455?app_id={appi}&app_key={key}", "{\"page\": 1,\"rows\": 50,\"query_fields\": {\"place_of_birth\": \"wales\"}}", array('Content-Type' => 'application/json'));
    $params = json_encode(['query_fields' => ["place_of_birth" => 'some string']]);
    $code = $result->info->http_code;
    if (!$code == 200) {
        echo "POST failed, error code: " . $code;
    }
    $response_json = $result->decode_response();
    return $response_json;
}
 /**
  * Stores the geopints with unique handler on the cloud. Geo points data
  * contains lat, lng and marker of the point.
  *
  * @param geoStorageName
  *            - Unique handler for storage name
  * @param geoPointsList
  *            - List of Geo Points to be saved
  *
  * @return Geo object containing List of Geo Points that have been saved
  */
 function createGeoPoints($geoStorageName, $geoPointsList)
 {
     Util::throwExceptionIfNullOrBlank($geoStorageName, "Geo Storage Name");
     Util::throwExceptionIfNullOrBlank($geoPointsList, "Geo Points List");
     $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;
         if (is_array($geoPointsList)) {
             $body = '{"app42":{ "geo": {"storage":{"storageName":"' . $geoStorageName . '" , "points": { "point": ' . json_encode($geoPointsList) . '}}}}}';
         } else {
             $body = '{"app42":{ "geo": {"storage":{"storageName":"' . $geoStorageName . '" , "points": { "point": "' . $geoPointsList . '"}}}}}';
         }
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/createGeoPoints";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $geoResponseObj = new GeoResponseBuilder();
         $geoObj = $geoResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $geoObj;
 }
Exemple #6
0
<?php

// dummy example of RestClient
require_once 'include/untis/CommonUtils.php';
require_once 'include/RestClient.class.php';
$enteredUsername = "******";
//test account
$enteredPassword = "******";
$paras = array();
//$paras["callback"] = "?";
$paras["method"] = "login";
$paras["input_type"] = "JSON";
$paras["response_type"] = "JSON";
$json = getJSONObj();
$paras["rest_data"] = $json->encode(array(array("password" => $enteredPassword, "user_name" => $enteredUsername), "C3CRM", array("name" => "language", "value" => "en_US")));
$twitter = RestClient::post('http://crm123.sinaapp.com/rest.php', $paras);
//$twitter = RestClient::post( // Same for RestClient::get()
//            'http://crm123.sinaapp.com/rest.php?callback=?'
//            ,'{
//				method: "login",
//				input_type: "JSON",
//				response_type: "JSON",
//				rest_data: \'[{"password":"******","user_name":"'.$enteredUsername.'"},"C3CRM",{"name":"language","value":"en_US"}]\'
//			}'
//            ,''
//            ,''
//			,'application/json');
var_dump($twitter->getResponse());
echo "<br>aaaaaaaaaaaa<br>";
var_dump($twitter->getResponseCode());
echo "<br>bbbbbbbbbbb<br>";
 function executeDataDriven($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();
         $headerParams = array_merge($signParams, $metaHeaders);
         $body = null;
         $body = '{"app42":{"abtest":{"name":"' . $testName . '"}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/execute/data-driven";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $abTestRespObj = new ABTestResponseBuilder();
         $abTestObj = $abTestRespObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $abTestObj;
 }
 /**
  * Deducts the reward points from the earned rewards by a user.
  *
  * @param gameName
  *            - Name of the game for which reward points have to be deducted
  * @param gameUserName
  *            - The user for whom reward points have to be deducted
  * @param rewardName
  *            - The rewards for which reward points have to be deducted
  * @param rewardPoints
  *            - The points that have to be deducted
  *
  * @return Reward object containing the reward points that has been deducted
  */
 function redeemRewards($gName, $gUserName, $rewardName, $rewardPoints)
 {
     Util::throwExceptionIfNullOrBlank($gName, "Game Name");
     Util::throwExceptionIfNullOrBlank($gUserName, "User Name");
     Util::throwExceptionIfNullOrBlank($rewardName, "Reward Name");
     Util::throwExceptionIfNullOrBlank($rewardPoints, "Reward Point");
     $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":{"rewards":{"reward":{"gameName":"' . $gName . '","userName":"******","name":"' . $rewardName . '","points":"' . $rewardPoints . '"}}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/redeem";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $rewardResponseObj = new RewardResponseBuilder();
         $rewardObj = $rewardResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $rewardObj;
 }
 function addComment($userID, $itemID, $comment)
 {
     Util::throwExceptionIfNullOrBlank($userID, "User ID");
     Util::throwExceptionIfNullOrBlank($itemID, "Item ID");
     Util::throwExceptionIfNullOrBlank($comment, "Comment");
     $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":{"review":{"userId":"' . $userID . '","itemId":"' . $itemID . '","comment":"' . $comment . '"}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/comment";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $reviewResponseObj = new ReviewResponseBuilder();
         $reviewObj = $reviewResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $reviewObj;
 }
 /**
  * Adds an Item in the Cart with quantity and price. This method does not
  * take currency. Its the bonus of the App developer to maintainthe
  * currency. It takes only the price.
  *
  * @params cartID
  *            - The Cart Id into which item has to be added
  * @params itemID
  *            - The Item id which has to be added in the cart. If the
  *            Catalogue Service is used along with the Cart Service then the
  *            Item ids should be same.
  * @params itemQuantity
  *            - Quantity of the Item to be purchased
  * @params price
  *            - Price of the item
  *
  * @returns Cart object containing added item.
  *
  */
 function addItem($cartID, $itemID, $itemQuantity, $price)
 {
     Util::throwExceptionIfNullOrBlank($cartID, "Cart ID");
     Util::throwExceptionIfNullOrBlank($itemID, "Item ID");
     Util::throwExceptionIfNullOrBlank($itemQuantity, "Item Quantity");
     Util::throwExceptionIfNullOrBlank($price, "Price");
     $encodedItemID = Util::encodeParams($itemID);
     $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;
         $body = null;
         $body = '{"app42":{"cart":{"cartId":"' . $cartID . '", "item":{"quantity":"' . $itemQuantity . '","amount":"' . $price . '"}}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/item/" . $encodedItemID;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $cartResponseObj = new CartResponseBuilder();
         $cartObj = $cartResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $cartObj;
 }
 /**
  * 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;
 }
 function sendMessageToFriends($userName, $message)
 {
     Util::throwExceptionIfNullOrBlank($userName, "UserName");
     Util::throwExceptionIfNullOrBlank($message, "message");
     $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":{"buddy":{"userName":"******","message":"' . $message . '"}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/messageAll";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $buddyRespObj = new BuddyResponseBuilder();
         $buddyObj = $buddyRespObj->buildArrayResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $buddyObj;
 }
 function sendPushMessageToDevice($username, $deviceId, $message)
 {
     Util::throwExceptionIfNullOrBlank($username, "username");
     Util::throwExceptionIfNullOrBlank($message, "message");
     Util::throwExceptionIfNullOrBlank($deviceId, "deviceId");
     $encodedUsername = Util::encodeParams($username);
     $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":{"push":{"message":{"username":"******","payload":"' . $message . '","deviceId":"' . $deviceId . '","expiry":"' . Util::getUTCFormattedTimestamp() . '"}}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/sendMessageToDevice/" . $encodedUsername;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $pushResponseObj = new PushNotificationResponseBuilder();
         $pushObj = $pushResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $pushObj;
 }
 function postActivityWithTag($userID, $comment, $tagName)
 {
     Util::throwExceptionIfNullOrBlank($userID, "User Id");
     Util::throwExceptionIfNullOrBlank($comment, "Comment");
     Util::throwExceptionIfNullOrBlank($tagName, "TagName");
     $otherMetaHeaders = array();
     $otherMetaHeaders['tag'] = $tagName;
     $this->setOtherMetaHeaders($otherMetaHeaders);
     $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;
         for ($itemID = '', $i = 0, $z = strlen($a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') - 1; $i != 16; $x = rand(0, $z), $itemID .= $a[$x], $i++) {
         }
         $body = '{"app42":{"bravo":{"userId":"' . $userID . '","itemId":"' . $itemID . '","comment":"' . $comment . '"}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/comment";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $bravoResponseObj = new BravoBoardResponseBuilder();
         $bravoObj = $bravoResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $bravoObj;
 }
 /**
  * Creates a Item in a Category for a particular Catelogue
  *
  * @params catalogueName
  *            - Name of the Catalogue to which item has to be added
  * @params categoryName
  *            - Name of the Category to which item has to be added
  * @params itemData
  *            - Item Information that has to be added
  *
  * @returns Catalogue object containing added item.
  * @see ItemData
  *
  */
 function addItem($catalogueName, $categoryName, ItemData $itemData)
 {
     $imagePath = $itemData->getImage();
     Util::throwExceptionIfNullOrBlank($catalogueName, "Catalogue Name");
     Util::throwExceptionIfNullOrBlank($itemData, "Item Data");
     Util::throwExceptionIfNullOrBlank($categoryName, "Catagory Name");
     Util::throwExceptionIfNotValidImageExtension($imagePath, "imagePath");
     $encodedCatName = Util::encodeParams($catalogueName);
     $encodedCategoryName = Util::encodeParams($categoryName);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     //$file = fopen($filePath, r);
     if (!file_exists($itemData->image)) {
         throw new App42Exception("File Not Found");
     }
     //$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);
         $queryParams['catalogueName'] = $catalogueName;
         $queryParams['categoryName'] = $categoryName;
         $signParams = array_merge($queryParams, $signParams);
         $postParams = array();
         $postParams['itemId'] = $itemData->itemId;
         $postParams['name'] = $itemData->name;
         $postParams['description'] = $itemData->description;
         $postParams['price'] = $itemData->price;
         $params = array_merge($postParams, $signParams);
         $signature = urlencode($objUtil->sign($params));
         //die();
         $params['imageFile'] = "@" . $itemData->image;
         $headerParams['signature'] = $signature;
         $contentType = "multipart/form-data";
         $body = null;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/" . $encodedCatName . "/" . $encodedCategoryName . "/item";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $catalogueResponseObj = new CatalogueResponseBuilder();
         $catalogueObj = $catalogueResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $catalogueObj;
 }
 /**
  * Send message on the queue with an expiry. The message will expire if it is not pulled/dequeued before the expiry
  *  @param queueName The name of the queue to which the message has to be sent
  *  @param msg Message that has to be sent
  *  @param exp Message expiry time
  *  @return Queue object containing message which has been sent with its message id and correlation id
  */
 function sendMessage($queueName, $msg, $exp)
 {
     Util::throwExceptionIfNullOrBlank($queueName, "Queue Name");
     Util::throwExceptionIfNullOrBlank($msg, "Message");
     Util::throwExceptionIfNullOrBlank($exp, "Exipiration");
     $encodedQueueName = Util::encodeParams($queueName);
     $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['queueName'] = $queueName;
         $body = null;
         $body = '{"app42":{"payLoad":{"message":"' . $msg . '","expiration":' . $exp . '}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $this->messageUrl . "/" . $encodedQueueName;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $queueResponseObj = new QueueResponseBuilder();
         $queueObj = $queueResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $queueObj;
 }
 function uploadFileForFriends($name, $userName, $filePath, $fileType, $description)
 {
     Util::throwExceptionIfNullOrBlank($name, "File Name");
     Util::throwExceptionIfNullOrBlank($userName, "User Name");
     Util::throwExceptionIfNullOrBlank($filePath, "FilePath");
     Util::throwExceptionIfNullOrBlank($fileType, "UploadFileType");
     Util::throwExceptionIfNullOrBlank($description, "Description");
     $encodedUserName = Util::encodeParams($userName);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     //$file = fopen($filePath, r);
     if (!file_exists($filePath)) {
         throw new App42Exception("The file with the name '{$filePath}' not found ");
     }
     $body = null;
     try {
         $params = null;
         $uploadTypeObj = new UploadFileType();
         if ($uploadTypeObj->isAvailable($fileType) == "null") {
             throw new App42Exception("The file with  type '{$fileType}' does not Exist ");
         }
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $postParams = array();
         $postParams['name'] = $name;
         $postParams['userName'] = $userName;
         $postParams['type'] = $fileType;
         $postParams['description'] = $description;
         $params = array_merge($postParams, $signParams);
         $signature = urlencode($objUtil->sign($params));
         //die();
         $params['uploadFile'] = "@" . $filePath;
         $headerParams['signature'] = $signature;
         //CONTENT_TYPE == "multipart/form-data"
         $contentType = "multipart/form-data";
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/" . "friendsAll/" . $encodedUserName;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $uploadResponseObj = new UploadResponseBuilder();
         $uploadObj = $uploadResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $uploadObj;
 }
 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;
 }
 function testPostWithParams()
 {
     $c = RestClient::post($this->url . "/Foo/hello", array("name" => "diogo"));
     $this->assertEquals($c->getResponse(), "Hello , Diogo.");
 }
 /**
  * Map reduce function to search the target document. Please see detail
  * information on map-reduce http://en.wikipedia.org/wiki/MapReduce
  *
  * @params dbName
  *            - Unique handler for storage name
  * @params collectionName
  *            - Name of collection under which JSON doc needs to be searched
  * @params mapFunction
  *            - Map function to be used to search the document
  * @params reduceFunction
  *            - Reduce function to be used to search the document
  *
  * @return Returns the target JSON document.
  *
  */
 function mapReduce($dbName, $collectionName, $mapFunction, $reduceFunction)
 {
     Util::throwExceptionIfNullOrBlank($dbName, "DataBase Name");
     Util::throwExceptionIfNullOrBlank($collectionName, "Collection Name");
     Util::throwExceptionIfNullOrBlank($mapFunction, "Map Function");
     Util::throwExceptionIfNullOrBlank($reduceFunction, "Reduce Function");
     $encodedDbName = Util::encodeParams($dbName);
     $encodedCollectionName = Util::encodeParams($collectionName);
     $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":{"storage":{"map":"' . $mapFunction . '","reduce":"' . $reduceFunction . '"}}}';
         $signParams['body'] = $body;
         $signParams['dbName'] = $dbName;
         $signParams['collectionName'] = $collectionName;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/mapReduce" . "/dbName" . "/" . $encodedDbName . "/collectionName" . "/" . $encodedCollectionName;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $response;
 }
 /**
  * Sets attribute in a session whose session id is provided. Attributes are
  * stored in a key value pair.
  *
  * @param sessionId
  *            - Session id for which the attribute has to be saved.
  * @param attributeName
  *            - The attribute key that needs to be stored
  * @param attributeValue
  *            - The attribute value that needs to be stored
  *
  * @return Session object containing the attribute and value which is stored
  */
 function setAttribute($sessionId, $attributeName, $attributeValue)
 {
     Util::throwExceptionIfNullOrBlank($sessionId, "session Id");
     Util::throwExceptionIfNullOrBlank($attributeName, "Attribute Name");
     Util::throwExceptionIfNullOrBlank($attributeValue, "Attribute Value");
     $encodedSessionId = Util::encodeParams($sessionId);
     $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;
         $signParams['sessionId'] = $sessionId;
         $body = '{"app42":{"session":{"name":"' . $attributeName . '","value":"' . $attributeValue . '"}}}';
         $signParams['body'] = $body;
         $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::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $sessionResponseObj = new SessionResponseBuilder();
         $sessionObj = $sessionResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $sessionObj;
 }
/**
 * @method
 *
 * Uplaod file/document in Alfresco Repository
 *
 * @name uploadDoc
 * @label Uplaod file/document in Alfresco Repository
 *
 * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
 * @param string | $fileSource | File Source
 * @param string | $title | File Title
 * @param string | $description | Description about File
 * @param string | $docType | Type of document to be Uploaded
 * @param string | $user | Valid Admin username to connect to Alfresco server
 * @param string | $pwd | Valid Admin password to connect to Alfresco server
 *
 * @return string | $result | Response
 *
 */
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd)
{
    $filep = fopen($fileSource, "r");
    $fileLength = filesize($fileSource);
    $fileContent = fread($filep, $fileLength);
    $fileContent = base64_encode($fileContent);
    $alfresco_url = "{$alfrescoServerUrl}/s/cmis/p/Sites/children";
    $xmlData = array();
    $xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>' . $title . '</title><summary>' . $description . '</summary><content type="application/' . $docType . '">' . $fileContent . '</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
    $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
    $sXmlArray = $alfresco_exec->getResponse();
    $sXmlArray = trim($sXmlArray);
    $xXmlArray = simplexml_load_string($sXmlArray);
    $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
    var_dump($aXmlArray);
    return $aXmlArray;
}
 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;
 }
 function distributeGifts($name, $recipients, $counts)
 {
     Util::throwExceptionIfNullOrBlank($name, "Name");
     Util::throwExceptionIfNullOrBlank($recipients, "Recipients");
     $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;
         if (is_array($recipients)) {
             $body = '{"app42":{"gift":{"name":"' . $name . '","counts":"' . $counts . '","expiry":"' . date("Y-m-d\\TG:i:s") . substr((string) microtime(), 1, 4) . "Z" . '","recipient":' . json_encode($recipients) . '}}}';
         } else {
             $body = '{"app42":{"gift":{"name":"' . $name . '","sender":"' . $sender . '","expiry":"' . date("Y-m-d\\TG:i:s") . substr((string) microtime(), 1, 4) . "Z" . '","recipient":' . json_encode($recipients) . '}}}';
         }
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/sendtousers";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $giftResponseObj = new GiftResponseBuilder();
         $giftObj = $giftResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $giftObj;
 }
 /**
  * Perform REST POST request to API
  * @param string $path Absolute resource path
  * @param array $params Post params
  * @return array
  */
 protected function _post($path, $params)
 {
     $uri = self::getBaseUri() . $path;
     $client = RestClient::post($uri, $params, $this->_user, $this->_password, "multipart/form-data", self::$baseHeaders);
     if ($client->getResponseCode() !== 200) {
         throw new Exception(trim($client->getResponseMessage()) . ": " . trim($client->getResponse()));
     }
     if ($client->getResponseContentType() != 'application/json') {
         throw new Exception("Unexpected response type: " . $client->getResponseContentType());
     }
     $result = json_decode($client->getResponse());
     if ($result->success === false) {
         throw new Exception("Nets fees request failed: {$result->message}");
     }
     return $result->data;
 }
 /**
  * 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;
 }
/**
 * @method
 *
 * Uplaod file/document in Alfresco Repository
 *
 * @name uploadDoc
 * @label Uplaod file/document in Alfresco Repository
 *
 * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
 * @param string | $fileSource | File Source
 * @param string | $title | File Title
 * @param string | $description | Description about File
 * @param string | $docType | Type of document to be Uploaded
 * @param string | $user | Valid Admin username to connect to Alfresco server
 * @param string | $pwd | Valid Admin password to connect to Alfresco server
 * @param string | $path | Path of document to be Uploaded
 * @param string | $mainFolder | The main folder in alfreco to save the files
 *
 * @return object | $result | Response |
 *
 */
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '', $mainFolder = 'Sites')
{
    if (!file_exists($fileSource)) {
        $result = new stdclass();
        $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $fileSource));
        return $result;
    }
    $filep = fopen($fileSource, "r");
    $fileLength = filesize($fileSource);
    $fileContent = fread($filep, $fileLength);
    $fileContent = base64_encode($fileContent);
    if ($path != '') {
        createFolder($alfrescoServerUrl, $mainFolder, $path, $user, $pwd);
        $path = $path . PATH_SEP;
    }
    $alfresco_url = "{$alfrescoServerUrl}/s/cmis/p/{$mainFolder}/" . $path . "children";
    $xmlData = array();
    $xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>' . $title . '</title><summary>' . $description . '</summary><content type="application/' . $docType . '">' . $fileContent . '</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
    $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
    $sXmlArray = $alfresco_exec->getResponse();
    $sXmlArray = trim($sXmlArray);
    $xXmlArray = simplexml_load_string($sXmlArray);
    $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
    return $aXmlArray;
}
 /**
  * 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;
 }
$senha1 = $_POST['senha1'];
$login = $_POST['login'];
//Verificar os campos obrigatórios, os tipos e formatos dos dados avaliados
if (validarCamposNaoVazios()) {
    if (validaFormCadastrarAluno()) {
        $json = array("nome" => $aluno, "login" => $login, "senha" => $senha1, "matricula" => $matricula, "nascimento" => $nascimento, "nivel" => $nivel, "sexo" => $sexo);
        // Instaciação do objeto RestClient. A url base é passada como parâmetro
        // via array.
        $restClient = new RestClient(array('base_url' => "http://localhost/NutrIF_service"));
        /*
         * Informar qual é o serviço ('cadastrarAluno'), os dados do json ($json) e
         * o header do HTTP ($header);
         */
        $header = array('user_agent' => "nutrif-php/1.0", 'content-type' => "application/json");
        // Método POST.
        $result = $restClient->post('cadastrarAluno', $json, $header);
        $code = $result->info->http_code;
        if ($code == 200 || $code == 201) {
            echo '<script language="javascript" type="text/javascript">';
            echo 'window.alert("Cadastro realizado com sucesso!");';
            echo 'window.location.href="index.php";';
            echo '</script>';
        } else {
            header("location: mensagem_erro.php");
        }
    } else {
        //jogar na sessão as variaveis do formulário
        $_SESSION['nascimento'] = $nascimento;
        $_SESSION['nome_aluno'] = $aluno;
        $_SESSION['matricula'] = $matricula;
        $_SESSION['nivel'] = $nivel;
 function createUserWithProfile($uName, $pwd, $emailAddress, Profile $profile)
 {
     Util::throwExceptionIfNullOrBlank($uName, "User Name");
     Util::throwExceptionIfNullOrBlank($pwd, "Password");
     Util::throwExceptionIfNullOrBlank($emailAddress, "Email Address");
     Util::throwExceptionIfEmailNotValid($emailAddress, "Email Address");
     Util::throwExceptionIfNullOrBlank($profile, "Profile Data");
     $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":{"user":{"userName":"******","password":"******","email":"' . $emailAddress . '", "profileData":{"firstName":"' . $profile->getFirstName() . '","lastName":"' . $profile->getLastName() . '","sex":"' . $profile->getSex() . '","mobile":"' . $profile->getMobile() . '","line1":"' . $profile->getLine1() . '","line2":"' . $profile->getLine2() . '","city":"' . $profile->getCity() . '","state":"' . $profile->getState() . '","country":"' . $profile->getCountry() . '","pincode":"' . $profile->getPincode() . '","homeLandLine":"' . $profile->getHomeLandLine() . '","officeLandLine":"' . $profile->getOfficeLandLine() . '","dateOfBirth":"' . (date("Y-m-d\\TG:i:s", strtotime($profile->getDateOfBirth())) . substr((string) microtime(), 1, 4) . "Z") . '"}}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         //CONTENT_TYPE;
         $accept = $this->accept;
         //ACCEPT;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/userwithprofile";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $userResponseObj = new UserResponseBuilder();
         $userObj = $userResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $userObj;
 }