public static function validate(CollectionData $data)
 {
     $reason = "";
     $articleId = $data->getArticleId();
     if (empty($articleId)) {
         $reason .= "\n Article id is null or blank.";
     }
     $title = $data->getTitle();
     if (empty($title)) {
         $reason .= "\n Title is null or blank.";
     } elseif (strlen($title) > 255) {
         $reason .= "\n Title is longer than 255 characters.";
     }
     $url = $data->getUrl();
     if (empty($url)) {
         $reason .= "\n URL is null or blank.";
     } elseif (!LivefyreUtils::isValidUrl($data->getUrl())) {
         $reason .= "\n URL is not a valid url. see http://www.ietf.org/rfc/rfc2396.txt.";
     }
     $type = $data->getType();
     if (empty($type)) {
         $reason .= "\n Type is null or blank.";
     } elseif (!CollectionType::isValidValue($type)) {
         $reason .= "\n Type is not of a valid type.";
     }
     if (strlen($reason) > 0) {
         throw new \InvalidArgumentException("Problems with your collection input:" . $reason);
     }
     return $data;
 }
 public function testSiteValidUrls()
 {
     $this->assertFalse(LivefyreUtils::isValidUrl("aawef"));
     $this->assertTrue(LivefyreUtils::isValidUrl("http://test.com:8000"));
     $this->assertTrue(LivefyreUtils::isValidUrl("http://test.com"));
     $this->assertTrue(LivefyreUtils::isValidUrl("https://test.com/"));
     $this->assertTrue(LivefyreUtils::isValidUrl("ftp://test.com/"));
     $this->assertTrue(LivefyreUtils::isValidUrl("http://清华大学.cn"));
     $this->assertTrue(LivefyreUtils::isValidUrl("http://www.mysite.com/myresumé.html"));
     $this->assertTrue(LivefyreUtils::isValidUrl("https://test.com/path/test.-_~!\$&'()*+,=:@/dash"));
 }
 public function isNetworkIssued()
 {
     $topics = $this->getData()->getTopics();
     if (!$topics || count($topics) === 0) {
         return false;
     }
     $urn = $this->getSite()->getNetwork()->getUrn();
     foreach ($topics as $topic) {
         $topicId = $topic->getId();
         if (LivefyreUtils::startsWith($topicId, $urn) && !LivefyreUtils::startsWith(str_replace($urn, "", $topicId), ":site=")) {
             return true;
         }
     }
     return false;
 }
 public static function validate(NetworkData $data)
 {
     $reason = "";
     $name = $data->getName();
     if (empty($name)) {
         $reason .= "\n Name is null or blank.";
     } elseif (!LivefyreUtils::endsWith($name, "fyre.co")) {
         $reason .= "\n Network name should end with '.fyre.co'.";
     }
     $key = $data->getKey();
     if (empty($key)) {
         $reason .= "\n Key is null or blank.";
     }
     if (strlen($reason) > 0) {
         throw new \InvalidArgumentException("Problems with your network input:" . $reason);
     }
     return $data;
 }
 private static function getHeaders(Core $core, $userToken = null)
 {
     $network = LivefyreUtils::getNetworkFromCore($core);
     $token = $userToken === null ? $network->buildLivefyreToken() : $userToken;
     return array("Authorization" => "lftoken " . $token, "Content-Type" => "application/json");
 }
示例#6
0
 public static function bootstrap(Core $core)
 {
     $network = LivefyreUtils::getNetworkFromCore($core);
     return $network->isSsl() ? sprintf("https://%s.bootstrap.fyre.co", $network->getNetworkName()) : sprintf("http://bootstrap.%s.fyre.co", $network->getNetworkName());
 }