开发者

get contents of URL like facebook wall post

开发者 https://www.devze.com 2023-03-11 08:34 出处:网络
i\'m using obsocial submit to submit articles from joomla to facebook. It publishes just one line w开发者_如何学JAVAith a link to the article.

i'm using obsocial submit to submit articles from joomla to facebook. It publishes just one line w开发者_如何学JAVAith 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号