コード例 #1
0
ファイル: LikeObjectBuilder.php プロジェクト: sgoendoer/sonic
 public function build()
 {
     if ($this->objectID == NULL) {
         $this->objectID = UOID::createUOID();
     }
     if ($this->datePublished == NULL) {
         $this->datePublished = XSDDateTime::getXSDDateTime();
     }
     if (!UOID::isValid($this->objectID)) {
         throw new IllegalModelStateException('Invalid objectID');
     }
     if (!UOID::isValid($this->targetID)) {
         throw new IllegalModelStateException('Invalid targetID');
     }
     if (!GID::isValid($this->author)) {
         throw new IllegalModelStateException('Invalid author');
     }
     if (!XSDDateTime::validateXSDDateTime($this->datePublished)) {
         throw new IllegalModelStateException('Invalid datePublished');
     }
     $like = new LikeObject($this);
     if ($like->getSignature() == NULL) {
         $like->signObject();
     }
     if (!$like->verifyObjectSignature()) {
         throw new IllegalModelStateException('Invalid signature');
     }
     return $like;
 }
コード例 #2
0
 public function createPOSTLike(LikeObject $likeObject)
 {
     $this->request = new OutgoingRequest();
     $this->request->setServer($this->getDomainFromProfileLocation($this->targetSocialRecord->getProfileLocation()));
     $this->request->setPath($this->getPathFromProfileLocation($this->targetSocialRecord->getProfileLocation()) . $this->targetSocialRecord->getGlobalID() . '/' . self::RESOURCE_NAME_LIKE);
     $this->request->setRequestMethod('POST');
     $this->request->setRequestBody($likeObject->getJSONString());
     return $this;
 }