/**
  *
  * @return array
  */
 public function getUsers()
 {
     $ids = $this->getListParameter(self::$USER_ID);
     if (empty($ids)) {
         if ($this->token->getViewerId() != null) {
             // Assume @me
             $ids = array("@me");
         } else {
             throw new IllegalArgumentException("No userId provided and viewer not available");
         }
     }
     $userIds = array();
     foreach ($ids as $id) {
         $userIds[] = UserId::fromJson($id);
     }
     return $userIds;
 }
 public function createActivity($userId, $groupId, $appId, $fields, $activity, SecurityToken $token)
 {
     try {
         if ($token->getOwnerId() != $token->getViewerId()) {
             throw new SocialSpiException("unauthorized: Create activity permission denied.", ResponseError::$UNAUTHORIZED);
         }
         ATutorDbFetcher::get()->createActivity($userId->getUserId($token), $activity, $token->getAppId());
     } catch (SocialSpiException $e) {
         throw $e;
     } catch (Exception $e) {
         throw new SocialSpiException("Invalid create activity request: " . $e->getMessage(), ResponseError::$INTERNAL_ERROR);
     }
 }
 public function getUserId(SecurityToken $token)
 {
     switch ($this->type) {
         case 'viewer':
             return $token->getViewerId();
             break;
         case 'owner':
             return $token->getOwnerId();
             break;
         case 'userId':
             return $this->userId;
             break;
         default:
             throw new Exception("The type field is not a valid enum: {$this->type}");
             break;
     }
 }
 private static function addIdentityParams(array &$params, SecurityToken $token)
 {
     $params['opensocial_owner_id'] = $token->getOwnerId();
     $params['opensocial_viewer_id'] = $token->getViewerId();
     $params['opensocial_app_id'] = $token->getAppId();
     $params['opensocial_app_url'] = $token->getAppUrl();
 }
 private function addOpenSocialParams(&$msgParams, SecurityToken $token, $signOwner, $signViewer)
 {
     if ($signOwner) {
         $owner = $token->getOwnerId();
         if ($owner != null) {
             $msgParams[SigningFetcher::$OPENSOCIAL_OWNERID] = $owner;
         }
     }
     if ($signViewer) {
         $viewer = $token->getViewerId();
         if ($viewer != null) {
             $msgParams[SigningFetcher::$OPENSOCIAL_VIEWERID] = $viewer;
         }
     }
     if ($signOwner || $signViewer) {
         $app = $token->getAppId();
         if ($app != null) {
             $msgParams[SigningFetcher::$OPENSOCIAL_APPID] = $app;
         }
         $url = $token->getAppUrl();
         if ($url != null) {
             $msgParams[SigningFetcher::$OPENSOCIAL_APPURL] = $url;
         }
     }
 }