Ejemplo n.º 1
0
 function testNormalizeStashID()
 {
     $result = CoreUtils::nomralizeStashID('76dfg312kla');
     self::assertEquals('076dfg312kla', $result);
     $result = CoreUtils::nomralizeStashID('76dfg312kla4');
     self::assertEquals('76dfg312kla4', $result);
     $result = CoreUtils::nomralizeStashID('000adfg312kla4');
     self::assertEquals('0adfg312kla4', $result);
 }
Ejemplo n.º 2
0
 /**
  * Makes a call to the dA oEmbed API to get public info about an artwork
  * $type defaults to 'fav.me'
  *
  * @param string      $ID
  * @param null|string $type
  *
  * @return string
  */
 static function oEmbed($ID, $type)
 {
     if (empty($type) || !in_array($type, array('fav.me', 'sta.sh'))) {
         $type = 'fav.me';
     }
     if ($type === 'sta.sh') {
         $ID = CoreUtils::nomralizeStashID($ID);
     }
     try {
         $data = DeviantArt::request('http://backend.deviantart.com/oembed?url=' . urlencode("http://{$type}/{$ID}"), false);
     } catch (CURLRequestException $e) {
         if ($e->getCode() == 404) {
             throw new \Exception("Image not found. The URL may be incorrect or the image has been deleted.");
         } else {
             throw new \Exception("Image could not be retrieved (HTTP {$e->getCode()})");
         }
     }
     return $data;
 }