<?php $url = 'http://bergie.iki.fi/blog/'; $meta_name = 'icbm'; $link_relation = 'alternate'; $anchor_relation = 'tag'; $client = new org_openpsa_httplib(); $html = $client->get($url); $meta_value = org_openpsa_httplib_helpers::get_meta_value($html, $meta_name); $link_values = org_openpsa_httplib_helpers::get_link_values($html, $link_relation); $anchor_values = org_openpsa_httplib_helpers::get_anchor_values($html, $anchor_relation); echo "<p>\n"; echo " url '{$url}'<br>\n"; echo " value for meta tag {$meta_name}: {$meta_value}<br>\n"; echo " values for link rel '{$link_relation}'<pre>\n"; print_r($link_values); echo " </pre>\n"; echo " values for anchor rel '{$anchor_relation}'<pre>\n"; print_r($anchor_values); echo " </pre>\n"; echo "</p>\n";
private function _get_data_from_url($url) { //We have to hang on to the hKit object, because its configuration is done by require_once //and will thus only work for the first instantiation... static $hkit; if (is_null($hkit)) { require_once MIDCOM_ROOT . '/external/hkit.php'; $hkit = new hKit(); } $data = array(); // TODO: Error handling $client = new org_openpsa_httplib(); $html = $client->get($url); // Check for ICBM coordinate information $icbm = org_openpsa_httplib_helpers::get_meta_value($html, 'icbm'); if ($icbm) { $data['icbm'] = $icbm; } // Check for RSS feed $rss_url = org_openpsa_httplib_helpers::get_link_values($html, 'alternate'); if ($rss_url && count($rss_url) > 0) { $data['rss_url'] = $rss_url[0]['href']; // We have a feed URL, but we should check if it is GeoRSS as well midcom::get('componentloader')->load_library('net.nemein.rss'); $rss_content = net_nemein_rss_fetch::raw_fetch($data['rss_url']); if (isset($rss_content->items) && count($rss_content->items) > 0) { if (array_key_exists('georss', $rss_content->items[0]) || array_key_exists('geo', $rss_content->items[0])) { // This is a GeoRSS feed $data['georss_url'] = $data['rss_url']; } } } $hcards = @$hkit->getByURL('hcard', $url); if (is_array($hcards) && count($hcards) > 0) { // We have found hCard data here $data['hcards'] = $hcards; } return $data; }