示例#1
0
 /**
  * Get content of an experience for SPVT
  * @param String $experienceId: id of the SharcExperience         
  * @param String $userId: id of the SharcUser
  */
 public static function getExperienceSnapshotForSpvt($experienceId, $userId)
 {
     $response = array();
     try {
         //Check if the designerId owns the experience
         $rs = SharcExperience::find($experienceId);
         if ($rs == null || $rs->isPublished == 0) {
             //Not exists
             $response["status"] = FAILED;
             $response["data"] = EXPERIENCE_NOT_EXIST;
             return $response;
         } else {
             $response = ExperienceService::getSnapshotForSpvt($rs->designerId, $experienceId, $userId);
         }
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }
示例#2
0
文件: index.php 项目: TrienDo/SHARC20
    $rs = UserService::checkAuthentication($app->request->headers->get('apiKey'));
    if ($rs["status"] != SUCCESS) {
        Utils::echoResponse($rs);
        return;
    }
    $userId = $rs['data']->id;
    //So even with a valid apiKey, the designer can access her own resources only
    $response = ExperienceService::getExperienceOfConsumer($userId);
    Utils::echoResponse($response);
});
//Get content of an experience for SPVT
$app->get('/experienceSnapshotForSpvt/:experienceId/:userId', function ($experienceId, $userId) use($app) {
    $rs = UserService::checkAuthentication($app->request->headers->get('apiKey'));
    if ($rs["status"] != SUCCESS) {
        Utils::echoResponse($rs);
        return;
    }
    $userId = $rs['data']->id;
    //So even with a valid apiKey, the designer can access her own resources only
    $response = ExperienceService::getExperienceSnapshotForSpvt($experienceId, $userId);
    Utils::echoResponse($response);
});
$app->map('/hello', function () {
    echo "Welcome to SHARC 2.0 RESTful Web services";
})->via('GET', 'POST');
$app->map('/test/:designerId/:experienceId', function ($designerId, $experienceId) {
    //$results = Capsule::se DB::s:select('select * from SharcUsers where id = ?', array(5));
    //echo $results->toJson();
    echo MediaService::getMediaSizeForExperience($designerId, $experienceId);
})->via('GET');
$app->run();