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?
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
the link goes through http://www.facebook.com/l.php
You pass a URL to this and facebook filters it.
Related
I read some RSS feeds and they give as Text/News only a short peace of the Original Message.
I tried to take the given URL to original Article and try to get the content.
But i don't know how i can extract the relevant text part of the page.
Without Menu, Advertising, footer text etc.
Has anybody a idea how i can make this better?
Maybe there exists a PHP library which do this very good?
For example Facebook makes here a good job, when i post a link of my Websites (without any Facebook specific code), they detect the relevantt text part automatically.
Hope someone can help me a little bit.
I've been doing some research and I have yet to find any information that is relevant to what I'm looking for. I've included some links to questions I've already found when they're relevant.
I made a page in WordPress (though the CMS isn't necissarily relevant), and one page has a series of comments. Before each comment, I created an anchor tag, so that if you go to the URL "http://website.com/#10", you'll be brought to the tenth comment. The URL and anchors work fine.
I am now trying to integrate Facebook Share functionality into the site. Specifically, I want to be able to share the URL "http://website.com/#10", with the #10 included, such that a user will be able to share a specific comment on social media and not just the entire comments page.
Following the Facebook Share Dialog example, located here, I crafted a URL that looks like this:
https://www.facebook.com/dialog/share?
app_id=XXXXXXXXXXXXXX
&display=popup
&href=http%3A%2F%2Fwebsite.com%2F%2310
&redirect_uri=XXXXXXXXXXXXXX
With all of the X's filled in with valid information. Note that the "href" parameter is "http%3A%2F%2Fwebsite.com%2F%2310", which is an encoded version of "http://website.com/#10". The "#" symbol is encoded as "%23".
This URL works relatively well for sharing. When I click on it, I'm brought to Facebook, which gives me the same dialog box they show on the Share Dialog developers page. However, after clicking on "Post to Facebook", I find that the actual URL that gets shared is, in fact, "http://website.com/?fb_action_ids=XXXXX&fb_action_types=og.shares". No "#10" anywhere in the URL.
Here's some information on the research I've done, to show that this is a new question (and to remove any repeated answers).
This question asks something quite similar to what I'm asking, and the only answer mentions a way to use Javascript to change all "#" symbols to "%23". However, I have already encoded my URL to do this, so the answer isn't relevant.
This question asks what I believe is a similar question, and the accepted answer basically says that the Share button is deprecated and continues by answering about the Like button. However, while the Share functionality may have once been deprecated, there is a fully working version on developers.facebook.com which I have already linked to. I would like to use this version, but with the ability to share links that include anchor tags.
Does anyone have any advice for how to proceed?
Using dialog does not seems to allow the URL to have #10, as you need.
Instead you may use, for exemple:
https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.terra.com.br%2F%23dia-13&display=popup&ref=plugin;
What can be done is to open a window by javascript, using this URL, where u refers to URL.
So far, there isn't a documentation that describes what parameters can be used with the URL. What is known is that images, title and description may be declared by <meta> tags using og:image, for example, to ensure some default content.
As stated here: http://okaypl.us/blog/facebook-share-dialog-longer-accepts-custom-parameters/
Some old parameters that probably are not working anymore are found in similar questions like:
how to pass parameter like title,summary and image in facebook sharer url.
I run ads on my site which are usually YouTube videos. I would like to find out if a user clicked these videos. I'm basically trying to use this data in a statistics plugin that I'm creating.
I've tried searching many different keywords but I can't really find anything.
I would appreciate it if I could be pointed in the right direction. Any ideas, hints or links are welcomed.
As you mention YouTube I doubt you have control over the URL.
But, if you can control the URL embedded in the video, then I would suggest building a simple redirect script on your server. Make sure the URL contains either the redirect URL or a code representing the URL which would be held in your Data Base. Add a logging function to the redirect script and hey presto.
If you have no control over the URL, then off the top of my head maybe you could implement some client side JS to add an overlay to the video which becomes the click-able element and implement the URL redirect script above. Some methods to get the URL from the video: https://www.google.com/search?q=jquery+youtube+URL
I'm making a website based fully on Ajax, but i'm still doubting about my SEO.
In my "a" tags href I put a Direct link to the content, but i don't redirect the user to it, instead i get the content by Ajax, then I change the Address bar with "window.location.hash".
If i send to Google my sitemap with the two links (the hash link and the direct link) is that going to be a duplicate content and hurt my SEO or not.
If you have any better way to do this (instead of my way) please feel free to tell me about it.
Thanks Guys
Google has a useful guide here:
Making AJAX Applications Crawlable
For full ajax sites, you'll typically see the navigation of the site reflected in url hashes:
#/about or #/faq and so on. When that is the case, google will index the content of those ajax responses if you prefix the url structure with an exclamation point (!). This is called a hashbang. so:
#!/about would actually get indexed by google.... also you can throw those types of urls into your sitemap (i think)
Can someone tell me what happens when i enter a link into the Facebook Status Update Form and it loads up a mini info kinda thing of the website (I'm guessing its RSS or something?)
How do i implement this on my site using PHP?
What do i need to learn to be able to implement that?
It scrapes the page you are linking to. It doesn't have anything to do with RSS.
By looking at the HTML of the page it can get the page title for you and find all the images that can be used as a thumbnail.
Take a look at HTTP or cURL in the PHP manual for methods to get webpage content.