Facebook Open Graph and custom share button - php

I've been working on a Joomla site with custom template, and I've had to create some custom share buttons for Google+, email, Twitter & Facebook. The first three work fine, but the Facebook one is causing problems. I'm using K2 and have got all the Open Graph meta tags within the header - having added the site_name & fb:app_id tags manually as K2 adds all the others, but not these. However, if I try to share a blog post Facebook doesn't pick up anything other than the URL.
I've tested with the Facebook debugger and all the meta information is being scraped. I know that it can take a while for the sharer to pick up any changes, and thanks to the debugger I discovered that I had to switch off gzip in order for the correct page to be loaded and the tags scraped. I made that change on Friday lunchtime, and have just checked the site again today and there is no change, the sharer is still coming back with empty data except for the URL.
I'm using this link (the URL is generated automatically by the site):
Share on Facebook
and the following Open Graph tags:
<meta property="og:url" content="http://www.mydomain.co.uk/blog/category/page-title">
<meta property="og:title" content="Page Title - My Domain">
<meta property="og:type" content="article">
<meta property="og:image" content="http://www.mydomain.co.uk/media/k2/items/cache/9b2c4b44fb86522964124ed80d03c5e8_M.jpg">
<meta name="image" content="http://www.mydomain.co.uk/media/k2/items/cache/9b2c4b44fb86522964124ed80d03c5e8_M.jpg">
<meta property="og:description" content="Page Intro Text">
Can anyone please suggest what I've missed or got wrong?
Thanks!

The URL you are using in sharer link is
http://www.mydomain.co.uk:80/blog/category/page-title
and the URL at og:url is
http://www.mydomain.co.uk/blog/category/page-title
i.e. there is a difference in both URLs (:80 in the URL at sharer link), so it may cause issue.
Try to use same URL both place. May it helps.

Related

Facebook SDK 5 post with byline

I've got the Facebook SDK working to auto post blog posts to my Facebook page, but I can't seem to get the post byline/author to appear.
If I share the URL directly to the page, the the article author will show up, but it doesn't with the SDK.
The docs show a variety of variables you can send, but no examples or much more information. The two options which look promising are admin_creator or from.
admin_creator says it requires an object[] with id and name but no examples to show what and how to pass this to the API. Anything I've tried doesn't work (such as profile ID and profile name), and the from I've tried passing a profile ID to no avail.
If anyone has done this can you help? Thanks!
SDK docs ref: https://developers.facebook.com/docs/graph-api/reference/v2.8/post/
Shared manually:
via SDK:
Does the metatag "Author" exist in your articles? Try to use the Object Debugger (https://developers.facebook.com/tools/debug/og/object/) and check if the "Author"'s name comes out. If not, the first thing is to understand why it doesn't appear.
Option 1: you missed the metatag in your code.
<meta name="author" content="Your name">
You can also add these metatags. The first one explicit the object type (article) while the second one links the author's name to an URL (like your FB's profile page):
<meta property="og:type" content="article"/>
<meta property="article:author" content="yourlink.com"/>
Option 2: if you're already using all these metatags you may have some cache problem. Are you sure that the Facebook Spider's can read your metatags? Maybe are you exposing a version of the article that misses the metatags?

Canonical url being linked on Facebook rather than real URL. Dynamic OpenGraph tags coming up wrong

I have a link curation website, so the problem is when I share a resource at the moment, the url could be for example http://mixtalker.com/?resources=looping-traktor-track-decks but facebook will scrape http://mixtalker.com/ because that is the canonical url.
This really sucks when someone posts it on facebook because all the OpenGraph tags are with the homepage meta, so the link gets the wrong thumbnail and wrong information. Who knows how to fix this?
Ps: Everything its ok with other pages, like about, faq, etc. I have this bug only with the link content page. Im Using Yoast SEO and Wordpress
This is in the source:
<meta property="og:url" content="http://mixtalker.com/" />
You need to change that metatag to include the parameter:
<meta property="og:url" content="http://mixtalker.com/?resources=looping-traktor-track-decks" />

Linkedin sharing urls / not parsing open graph

The Linkedin documentation can be found here
As it says, it needs:
og:title
og:description
og:image
og:url
Here is an example of my wordpress blog source code that for simplicity I use Jetpack plug-in:
<!-- Jetpack Open Graph Tags -->
<meta property="og:type" content="article" />
<meta property="og:title" content="Starbucks Netherlands Intel" />
<meta property="og:url" content="http://lorentzos.com/starbucks-netherlands-intel/" />
<meta property="og:description" content="Today I had some free time at work. I wanted to play more with Foursquare APIs. So the question: "What is the correlation of the Starbucks Chain in the Netherlands?". Methodology: I found all the p..." />
<meta property="og:site_name" content="Dionysis Lorentzos" />
<meta property="og:image" content="http://lorentzos.com/wp-content/uploads/2013/08/starbucks-intel-nl-238x300.png" />
In Facebook it works great, or you can see the meta data here. However LinkedIn is more stubborn and doesn't really parse the data even the If you're unable to set Open Graph tags within the page that's being shared, LinkedIn will attempt to fetch the content automatically by determining the title, description, thumbnail image, etc.
I know that I don't have the og:image:width tag but Linkedin doesn't even parse title, description or url. Any ideas to debug it?
I checked again my html and found some warnings/errors in metadata. I fixed them and all work good. So the solution if you encounter the same problem:
Check your html again and debug it. Even if the page load well in your browser, the LinkedIn parser is not as powerful in terms of small errors. This tool might help.
My very first suggestion is appending a meaningless query to the URL, so that LinkedIn thinks it's a new link (this doesn't affect anything else) i.e.:
http://example.com/link.php?42 or http://example.com/link.html?refid=LinkedIn
If that doesn't suit your needs, a more drastic measure is in order.
After making sure you don't have any errors in your console and validating your site using:
http://validator.w3.org/...
Add the prefix attribute to every tag (not to html tag), then re-sign in with your LinkedIn account to clear the cache...
prefix="go: http://ogp.me/ns#" i.e.:
<meta prefix="og: http://ogp.me/ns#" property="og:title" content="Title of Page" />
<meta prefix="og: http://ogp.me/ns#" property="og:type" content="article" />
<meta prefix="og: http://ogp.me/ns#" property="og:image" content="http://example.com/image.jpg" />
<meta prefix="og: http://ogp.me/ns#" property="og:url" content="http://example.com/" />
I hope one of these three solutions works for someone. Cheers!
If you're sure you've done everything right (using open graph meta tags, no errors on validator.w3.org) and it still is not working, be sure to try it with a different page, it might be a LinkedIn cache thing.
I had a <h1>Project information</h1> on my page, which LinkedIn used as the title for sharing the page, instead of the <title> or <meta property="og:title" [...]/> tag. Even though I did everything right. But when I completely removed this <h1>Project information</h1> from the page source, it kept using 'Project information' as the title even thought it wasn't on the page anymore.
After trying a different page, it worked.
I stumbled about the same problem for our Wordpress site. The problem is created by conflicting OGP and oembed headers in standard wordpress + yoast / jetpack seo plugin.
You need to disabled the oembed headers with this plugin (this has no side effects): https://wordpress.org/plugins/disable-embeds/
After that you can force a fresh link preview by appending a ?1 as some of you guys already pointed out!
I hope that fixes your problem.
I wrote a detailed explanation for the problem here: https://pmig.at/2017/10/26/linkedin-link-preview-for-wordpress/
Linkedin caches the urls so it's very practical to make sure that this is not your problem before starting to debug.
This might tool then might come in handy: https://www.linkedin.com/post-inspector/inspect/
Here you can preview your url and see how it looks like when sharing. It refreshes the caching as well so you can be sure if you have a problem or if it was the caching only.
After a long trial and error I found out that my .htaccess was somehow blocking the Linkedin robot (wordpress site). For those who use the ithemes security plugin for wordpress or another security plugin make sure that LinkedIn is not blocked.
Make sure there is no line like:
RewriteCond %{HTTP_USER_AGENT} ^Link [NC,OR]
The easiest way to check is to use wordpress default htaccess lines.
As mentioned before, make sure you don't retry cached pages in linkedin.
You can try this only once a week!
I had a link to my site and I wanted to customize the image Linkedin displayed. So I added open graph tags which didn't seem to render at all. Until I read this:
The first time that LinkedIn's crawlers visit a webpage when asked to share content via a URL, the data it finds (Open Graph values or our own analysis) will be cached for a period of approximately 7 days.
This means that if you subsequently change the article's description, upload a new image, fix a typo in the title, etc., you will not see the change represented during any subsequent attempts to share the page until the cache has expired and the crawler is forced to revisit the page to retrieve fresh content.
https://developer.linkedin.com/docs/share-on-linkedin
The solution for me was to add a hashbang. I am on an ajax style application which doesn't render the whole page, I think linkedin has a bit of a hissy fit about the text/image not being on the page on initial scrape, adding
%23!
to the end of my encoded url or
#!
to the unencoded url before sending it off to linkedin seemed to do the trick nicely for my share button popup. Not wsure if this is only Ajax/js apps or not but it certainly solved a couple of hours of effort for me.
I guess this is only useful if your application is setup to handle the escape_fragment in the url and render a static page not a dynamic one but I can't test this theory right now
This was happening on one of my client's sites as well. I discovered that the .htaccess file was blocking the site from LinkedIn if the user-agents contained the string "jakarta".
As soon as I remove this filtering, LinkedIn was able to access all of the required the OpenGraph (og) information when the client would post a link.
True, the documentation states that you can have: title, url, description, and image. But in reality, you have two options. Pick one of the two following sets and use it, as you have no other choice...
Set 1 Options
og:title
og:url
og:image
Set 2 Options
og:title
og:url
og:description
That is the reason why og:description is mysteriously missing from preview links. But if you drop image, then your description will finally display.
Try it: Wikipedia has an og description but no og image, while GitHub has both. Share Wikipedia and Share GitHub. Clearly seems like either you get a choice to display description or a choice to display image. I have spent weeks struggling with LinkedIn Support to correct this, but to no avail.

Facebook Like Button Confirmation Page Says "The Page You Requested Was Not Found"

Just finished putting a like button on a website I was working on. Everything was working fine, but while testing, I guess I like and unliked too many times and got put on the click blacklist. That would be fine, except that the confirm button always says "The Page You Requested Was Not Found". Used the url linter and everything seems to be fine. I've double and triple checked my meta tags and iframe. I can't figure it out! Please help! Here's the website:
http://melissy.com/html/index.php
Here's the object properties of the page:
g:url: http://melissy.com/html/index.php
og:type: website
og:title: Melissa Davidson
og:image: (this is not blank, was shown as a picture on the debugger)
og:description: Southern California artist Melissa Davidsons official website. Includes painting and photo galleries, as well as event and contact information.
og:site_name: Melissa Davidson
And the Open Graph Metadata
meta property="og:title" content="Melissa Davidson"
meta property="og:type" content="website"
meta property="og:url" content="http://melissy.com/html/index.php"
meta property="og:image" content="(removed)"
meta property="og:site_name" content="Melissa Davidson"
meta property="fb:admins" content="(took this out for security purposes)"
meta property="og:description" content="Southern California artist Melissa Davidsons official website. Includes painting and photo galleries, as well as event and contact information."
I am looking forward to your advice. Thanks!
Problem solved! Just posting in case anybody else has this problem. I created the like button on the facebook like button generator:
http://developers.facebook.com/docs/reference/plugins/like/
When I generated the code, I picked "standard" layout. Later, I decided to change to "box-count". I changed the appropriate variable in the iframe url embedded on my page. All the code was correct. However, the button does not work unless it is set to "standard". I guess when you create the button on Facebook they create some kind of record which becomes permanently linked to the url

How to force facebook share button to share the url in a different format?

I use the following share button to my page. Unfortunately my urls that are shared through my page have Greek letters in it "as" below:
http://www.domain.com/gb/news/12/13311/the-name-of-article-written-in-greek.htm
and I guess this causes a problem where the facebook does not show any image or content of the page. It only shows the url.
I found out that if I manually cut the above url to
http://www.domain.com/gb/news/12/13311/
the share works properly and the current page is shown. Everything is great.
So my question is how should I force the facebook share button to share the page after the modification? I know that by using var_dump($url['dirname']); I get the format I want.
According to FB docs, you can specify any URL you wish by populating the SHARE_URL a tag attribute:
<a name="fb_share" type="button" share_url="<?php echo $url['dirname'] ?>"></a>
By the way, what you are referring to is a canonical url, trimming this:
http://www.domain.com/gb/news/12/13311/the-name-of-article-written-in-greek.htm
To this:
http://www.domain.com/gb/news/12/13311/
The beauty of canonical urls is that they will not change, even though you decide to change keywords in the pretty url version. Useful for sitemaps.
You can use the FaceBook OG (open graph) tags to tell facebook what the "real" url is of the page. If you're serious about facebook sharing, you should be using those already. Put these in your
<meta property="og:title" content="Titeel Goes Here"/>
<meta property="og:url" content="URL goes here"/>
Verify what Facebook sees here: https://developers.facebook.com/tools/debug. You can also add a thumbnail image, and admin (so you can better see the likes and who shared).

Categories