tags:

views:

40

answers:

1

When you posting a link on facebook they retrieve an image from that link's page and an overview of that page's content. Any ideas on how to have this kind of functionality?

Thanks in advance.

+1  A: 

It's not something that can be answered momentarily, but I can point you in the right direction. You have to read the Html page and parse it for all image tags. There are different ways of doing this, but as an example:

WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
string pageHtml = webClient.DownloadString(your_link_url);

Then you can search the string for <img> tags and read their src attributes. Facebook (and more recently MySpace) uses more complicated logic and rules to determine which images to grab (e.g. only certain size limits), so you can do something similar.

Btw, Facebook and MySpace recommend to use metatagging of content in order to "tell" their "fetchers" which images exactly they should fetch when sharing. So you could parse the page for those first, and if they are not present, continue with other images:

<meta name="title" content="TITLE_GOES_HERE" />
<meta name="description" content="EXCERPT_GOES_HERE" />
<link rel="image_src" href="IMAGE_URL_GOES_HERE" />

http://developerwiki.myspace.com/index.php?title=How_to_Add_Post_To_MySpace_to_Your_Site

Yakimych
Cool! thanks I will give it a try and update the question.
Argyris
Awesome it works...you just have to fine tune it so to work for each of the sites that you are interested in retrieving similar info.
Argyris