Пример #1
0
 /**
  * Test Method for creating the User in App42 Cloud. 
  */
 public function createUser()
 {
     App42API::initialize("API KEY", "SECRET KEY");
     $response = null;
     // FOR  Test Create USER
     $objUser = App42API::buildUserService();
     try {
         print " Starting User Creation test";
         $response = $objUser->createUser("admin", "test", "*****@*****.**");
     } catch (App42BadParameterException $ex) {
         // Exception Caught
         // Check if User already Exist by checking app error code
         if ($ex->getAppErrorCode() == 2001) {
             // Do exception Handling for Already created User.
         }
     } catch (App42SecurityException $ex) {
         // Exception Caught
         // Check for authorization Error due to invalid Public/Private Key
         if ($ex->getAppErrorCode() == 1401) {
             // Do exception Handling here
         }
     } catch (App42Exception $ex) {
         // Exception Caught due to other Validation
     }
     // Render the JSON response. This will return the Successful created
     // User response
 }
Пример #2
0
 protected function populateMetaHeaderParams()
 {
     $params = array();
     if ($this->pageOffset != -11) {
         $params[PAE_Constants::PAGE_OFFSET] = "" . $this->pageOffset;
     }
     if ($this->pageMaxRecords != -1) {
         $params[PAE_Constants::PAGE_MAX_RECORDS] = "" . $this->pageMaxRecords;
     }
     $this->setACLHeader($params);
     if ($this->geoTag != null) {
         $params[PAE_Constants::GeoTag] = $this->geoTag->getJSONObject();
     }
     if (count($this->getSelectKeys()) > 0) {
         $selectJSONKeys = new JSONObject();
         foreach ($this->selectKeys as $key) {
             $selectJSONKeys->put($key, PAE_Constants::SELECT_KEY_FLAG);
         }
         $params[PAE_Constants::SELECT_KEYS_HEADER] = $selectJSONKeys;
     }
     $params['SDKName'] = "Php";
     if ($this->event != null && $this->event != "") {
         $params['event'] = $this->event;
     }
     if (App42API::getLoggedInUser() != null && App42API::getLoggedInUser() != "") {
         $params['loggedInUser'] = App42API::getLoggedInUser();
     }
     if ($this->query != null && $this->query != "") {
         $params['metaQuery'] = $this->query;
     }
     if ($this->jsonObject != null && $this->jsonObject != "") {
         $params['jsonObject'] = $this->jsonObject;
     }
     if ($this->dbName != null && $this->dbName != "" && $this->collectionName != null && $this->collectionName != "") {
         $obj = new JSONObject();
         $obj->put("dbName", $this->dbName);
         $obj->put("collectionName", $this->collectionName);
         $params['dbCredentials'] = $obj->__toString();
     }
     // Add Other meta headers if available
     if (count($this->getOtherMetaHeaders()) > 0) {
         $keySet = $this->getOtherMetaHeaders();
         foreach ($keySet as $key => $value) {
             if ($key != null && !$key == "" && $value != null && $value != "") {
                 $params[$key] = $value;
             }
         }
     }
     return $params;
 }
Пример #3
0
 /**
  * Set Api Key and Secret Key of your App
  *
  * @param apiKey
  * @param secretKey
  */
 public static function initialize($apiKey, $secretKey)
 {
     self::$config = App42Config::getInstance();
     App42API::$apiKey = $apiKey;
     App42API::$secretKey = $secretKey;
 }
Пример #4
0
 public function addJSONObject($collectionName, $obj)
 {
     $this->dbName = App42API::getDbName();
     $this->collectionName = $collectionName;
     $this->jsonObject = json_encode($obj);
 }