简体   繁体   中英

get contents of URL like facebook wall post

i'm using obsocial submit to submit articles from joomla to facebook. It publishes just one line with a link to the article.

In facebook, when you paste or tyep a url, it automatically extracts the contents from the url with images if any.

Is there api available that i can use to achieve the same?

I found jquery liveUrl helpful for a similar usecase Working demo

<textarea style="width: 300px; height: 100px;" placeholder="write here"></textarea>
$('textarea').liveUrl({
                        success : function(data) 
                        {
    console.log(data);
    }
    });

this might help you abit

<?php
$site = file_get_contents ($url);

$meta = get_meta_tags ($url);
preg_match_all('/<img[^>]+>/i', $site, $result); 
preg_match('/<title>([^>]*)<\/title>/s', $temp, $title);
?>

I'm not aware of a class/api which provide such functionality. But it is not to hard to write your own.

You can use get_meta_tags() to grep all metatags of a certain page und filter for the graph tags. if they are present you have won. if not, you would have to parse the of the page to find the content by yourself. (see @Jobbdirekt Krostofer'S answer)

see http://developers.facebook.com/docs/opengraph/ for the Graph Meta Tags.

EDIT: Found a php class for parsing for graph meta tags: http://buzzword.org.uk/2010/opengraph/#php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM