public function buildCollectionMetaToken($title, $articleId, $url, $options = array()) { if (filter_var($this->_IDNA->encode($url), FILTER_VALIDATE_URL) === false) { throw new \InvalidArgumentException("provided url is not a valid url"); } if (strlen($title) > 255) { throw new \InvalidArgumentException("title length should be under 255 char"); } $collectionMeta = array("url" => $url, "title" => $title, "articleId" => $articleId); if (array_key_exists("type", $options) and !in_array($options["type"], self::$TYPE)) { throw new \InvalidArgumentException("type is not a recognized type. must be in " . implode(",", self::$TYPE)); } return JWT::encode(array_merge($collectionMeta, $options), $this->_key); }
public function validateLivefyreToken($lfToken) { $tokenAttributes = JWT::decode($lfToken, $this->_key); return $tokenAttributes->domain == $this->_name && $tokenAttributes->user_id == self::DEFAULT_USER && $tokenAttributes->expires >= time(); }
public static function removeSubscriptions($network, $userToken, $topics) { $userId = JWT::decode($userToken, $network->getKey())->user_id; $userUrn = $network->getUserUrn($userId); $data = json_encode(array("delete" => self::buildSubscriptions($topics, $userUrn))); $url = self::getSubscriptionUrl($network, $userUrn); $response = Client::PATCH($url, self::getHeaders($network, $userToken), $data); $body = self::getData($response); if (!property_exists($body, "removed")) { return 0; } return self::getData($response)->{"removed"}; }