예제 #1
0
 protected function parse($number)
 {
     $item = parent::parse($number);
     $item['source'] = 'Flickr';
     $item['publisher'] = 'Flickr';
     $item['license'] = '';
     $photosGetInfo_resp = $this->photosGetInfo($number);
     if ($photosGetInfo_resp['stat'] == 'ok') {
         $realname = $photosGetInfo_resp['photo']['owner']['realname'];
         $username = $photosGetInfo_resp['photo']['owner']['username'];
         $item['author'] = empty($realname) ? $username : $realname;
         // parse photo.urls.url
         $item['link'] = '';
         if (!empty($photosGetInfo_resp['photo']['urls']['url'])) {
             $item['link'] = $photosGetInfo_resp['photo']['urls']['url'][0]['_content'];
         }
         $license_id = $photosGetInfo_resp['photo']['license'];
         $photosLicensesGetInfo_resp = $this->photosLicensesGetInfo();
         $lic_array = $this->findLicensesById($license_id, $photosLicensesGetInfo_resp['licenses']['license']);
         if (empty($lic_array['url'])) {
             $item['license'] = $lic_array['name'];
         } else {
             $item['license'] = '<a href="' . $lic_array['url'] . '" target="__blank">' . $lic_array['name'] . '</a>';
         }
     } else {
         $item['info'] = $photosGetInfo_resp['code'] . ': ' . $photosGetInfo_resp['message'];
         // TODO: use only info block as soon as this implemented
         $item['author'] = $photosGetInfo_resp['code'] . ': ' . $photosGetInfo_resp['message'];
     }
     return $item;
 }
예제 #2
0
 protected function parse($number)
 {
     $url = self::BASE_URL . $number;
     $item = parent::parse($number);
     $item['source'] = 'Freeimages';
     $item['publisher'] = 'Freeimages';
     $item['license'] = 'Royalty-free';
     $item['link'] = $url;
     $doc = new DOMDocument();
     $response = $this->curl($url);
     $html = @$doc->loadHTML(wp_remote_retrieve_body($response));
     if ($html) {
         $xpath = new DOMXPath($doc);
         $tags = $xpath->query("//tr/td[contains(., 'Uploaded by')]/a");
         if (!is_null($tags) && $tags->length > 0) {
             $item['author'] = $tags->item(0)->textContent;
         }
     }
     return $item;
 }
예제 #3
0
 protected function parse($number)
 {
     $url = self::BASE_URL . $number;
     $item = parent::parse($number);
     $item['source'] = 'iStockphoto';
     $item['publisher'] = 'iStockphoto';
     $item['license'] = 'Royalty-free';
     $item['link'] = $url;
     $doc = new DOMDocument();
     $response = $this->curl($url);
     $html = @$doc->loadHTML(wp_remote_retrieve_body($response));
     if ($html) {
         $xpath = new DOMXPath($doc);
         $tags = $xpath->query("*/meta[@property='og:author']");
         if (!is_null($tags) && $tags->length > 0) {
             $item['author'] = $tags->item(0)->getAttribute('content');
         }
     }
     return $item;
 }