0

I'm building a website and am looking for a way to implement a certain feature that Facebook has. The feature that am looking for is the link inspector. I am not sure that is what it is called, or what its called for that matter. It's best I give you an example so you know exactly what I am looking for.

When you post a link on Facebook, for example a link to a youtube video (or any other website for that matter), Facebook automatically inspects the page that it leads you and imports information like page title, favicon, and some other images, and then adds them to your post as a way of giving (what i think is) a brief preview of the page to anyone reading that post.

I already have a feature that allows users to share a link (or URLs). What I want is to do something useful with the url, to display something other than just a plain link to a webpage, to give someone viewing a shared link (in the form if a post) some useful insight into the page that the url leads to.

What I'm looking for is a script, or tutorial, or at the very least someone to point me in the right direction, so that it can help me accomplish this (using PHP preferably). I've tried googling it but I don't know exactly what such a feature would be called and google isn't helpful when you don't exactly know what you're looking for. I figure someone out there, in this vast knowledge basket called stackoverflow, can help me with this. Can anyone help me?

nchima
  • 163
  • 1
  • 1
  • 5
  • Are you looking for something like: http://stackoverflow.com/questions/125951/command-line-program-to-create-website-screenshots-on-linux ? – sarnold Jan 22 '12 at 23:49
  • Can you clarify on what it is you want? Do you want a feature where the link is uploaded, or where it finds the link in user content and adds information about it? – mowwwalker Jan 22 '12 at 23:59
  • @walkerneo I already have a feature that allows users to share a links (or URLs). What I want is to do something useful with the url, to display something other than just a plain link to a webpage, to give someone view a post some useful insight into the page that the url leads to. Understand what am saying? – nchima Jan 23 '12 at 01:17

2 Answers2

0

You would first scan the page for URLs using regex, then you would parse the pages those links reference with a php DOMDocument. You could use the parsed document to obtain any information you need from the webpage.

DOMDocument:

http://php.net/manual/en/class.domdocument.php

DOMDocument->load (loads a file, aka a webpage):

http://php.net/manual/en/domdocument.load.php

mowwwalker
  • 16,634
  • 25
  • 104
  • 157
  • 1
    Scan the page for links using regular expressions?? Why? And I'm not sure this is really answering the OP's question, anyway. – Andrew Barber Jan 22 '12 at 23:44
  • @AndrewBarber, OP wants to post information about a link when it is found on his website. He will first have to know it's a link by searching the document for it, and then to get information from it, he will have to parse it. – mowwwalker Jan 22 '12 at 23:46
  • 1
    No; he wants to get information about a url when it is submitted to his site. Finding links isn't relevant; it's a url that's being submitted. And even if you were right there, regular expressions are *not* how that should be done. – Andrew Barber Jan 22 '12 at 23:48
  • @AndrewBarber, Actually, I think you're right about what he wants. I realize regex wouldn't be the best, but it's all I could think of. Assuming he wants what I was talking about, what would he use? – mowwwalker Jan 22 '12 at 23:53
  • @AndrewBarber, No, what I'm saying is if you have something like: `

    Hey guys, here's this super-cool website: http://stackoverflow.com

    `, You would use regex, right?
    – mowwwalker Jan 22 '12 at 23:56
  • Maybe, but it's not really what the question is about. It's also not what your answer says (a "link" implies something different than a "url") – Andrew Barber Jan 23 '12 at 00:00
  • I've already implemented a system that lets me identify links in a post. I also have a separate system that allows a user to share a link (or url) – nchima Jan 23 '12 at 01:09
-1

the link goes through http://www.facebook.com/l.php You pass a URL to this and facebook filters it.

Adam Fowler
  • 1,750
  • 1
  • 17
  • 18