diff --git a/server/index.php b/server/index.php new file mode 100644 index 00000000..4e803f04 --- /dev/null +++ b/server/index.php @@ -0,0 +1,96 @@ +loadHTML($html); + $nodes = $doc->getElementsByTagName('title'); + + $title = $nodes->item(0)->nodeValue; + $description = ""; + $keywords = ""; + $image = ""; + + $metas = $doc->getElementsByTagName('meta'); + + for ($i = 0; $i < $metas->length; $i++) + { + $meta = $metas->item($i); + if($meta->getAttribute('name') == 'description') + $description = $meta->getAttribute('content'); + if($meta->getAttribute('name') == 'keywords') + $keywords = $meta->getAttribute('content'); + if($meta->getAttribute('property')=='og:image'){ + $image = $meta->getAttribute('content'); + } + } + + return [ + 'image' => $image, + 'title' => $title, + 'description' => $description + ]; +} + +$url = get_url(); + +$url_params = parse_url($url); + +if (!$url) +{ + exit(0); +} + +$html = file_get_contents_curl($url); + +$result = get_meta_from_html($html); + +$result = array_merge( + + get_meta_from_html($html), + + array( + 'linkUrl' => $url, + 'linkText' => $url_params["host"] . $url_params["path"], + ) + +); + +echo json_encode($result); + +?> \ No newline at end of file