Lost FB likes after moving to SSL

Started by spiros, December 24, 2016, 08:02:19 AM

Previous topic - Next topic

spiros

I have changed to SSL and I lost all FB likes. I found these intructions:

And it looks like this bit:

<meta property="og:url"               content="' . $context['canonical_url'] . '" />
http://www.simplemachines.org/community/index.php?topic=546773.0

Should be modified so that og:url points to the http version of the page. How can this be done?


spiros

#1
OK, I got it:

<meta property="og:url" content="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '" />

But adding it did not seem to restore the Likes. Hmm, perhaps because it does not give a canonical URL.

So how to get canonical URL with http and not https?

aegersz

I dropped the fb likes and karma in favor of the Advanced Reputation System mod ... you may want to check it out.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

spiros

Not an option due to the high number of likes etc in some pages which are quite valuable.

aegersz

Understood -- but ARS can co-exist with your fb likes, i guess.

I obviously really like the ARS and my members actually told me to ditch the fb likes mod.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Arantor

<meta property="og:url"               content="' . str_replace('https://', 'http://', $context['canonical_url'], 1) . '" />

CMOBOSS

ARS appears to no longer be available through the link to mod, link, in the OP of this thread: http://www.simplemachines.org/community/index.php?topic=230676.2480

Can you tell me where it is now?

Quote from: Arantor on December 25, 2016, 03:55:57 AM
<meta property="og:url"               content="' . str_replace('https://', 'http://', $context['canonical_url'], 1) . '" />

Love your signature!!  ;)

spiros

Thanks, Arantor :) I got this:

Fatal error: Only variables can be passed by reference in ...forum/Themes/citiez_20a/index.template.php on line 142

Arantor

Take the ', 1' part off inside the str_replace call. I forgot that whereas with other functions, you can tell it to only replace one thing like this, str_replace will instead give you back the number of things it changed.

You shouldn't really have a situation where the canonical URL somehow contains a second https:// in it but I figured better safe than sorry...

spiros

#9
Thanks, Arantor, one more time that you help me, I cannot count the times really :)

Funnily enough, this method did not get the FB Likes back, if anyone is trying the same. Here is my Open Graph code in case it is helpful to anyone else:

<meta property="og:url" content="' . str_replace('https://', 'http://', $context['canonical_url']) . '" />
<meta property="og:type" content="website" />
<meta property="og:title" content="' . $context['page_title_html_safe'] . '" />
<meta property="og:description" content="' . $context['page_title_html_safe'] . '" />
<meta property="og:image" content="https://www.translatum.gr/forum/Themes/citiez_20a/images/translatumlogo.jpg" />
<meta property="og:image:width" content="250" />
<meta property="og:image:height" content="250" />
<meta property="fb:admins" content="100000773649123" />
<meta property="fb:app_id" content="133026706734105" />
<meta property="og:site_name" content="Translatum.gr />';


The Facebook debugger found as error a circular URL since I have htaccess redirects from http to https and the og:url is different from the canonical.

https://developers.facebook.com/tools/debug/

Kindred

actually, I am somewhat confused as to why Facebook would not accept https...   given that most, if not everyone, will be going to https shortly (or face penalties from google, etc) and given that facebook has required https for apps and itself for well over a year now...


I use https for a wordpress blog site... and facebook pulls those share and even the preview image just fine...


so, I honestly don't think that https is your actual issue

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

No, different thing, Kindred.

FB likes are based off the URL, which is why canonical is important but it seems like they base it on the actual URL rather than the declared canonical.

This is just part of why I dislike Facebook.

spiros

Quote from: Kindred on December 26, 2016, 08:15:50 AM
I use https for a wordpress blog site... and facebook pulls those share and even the preview image just fine...

Wordpress has the same issues when MOVING to SSL. Old likes are lost, there are hacks around: see

https://wordpress.org/support/topic/moved-to-https-likes-gone-can-i-specify-ogurl/
https://wordpress.org/support/topic/move-to-ssl-losing-likes/

Kindred

oh, I see....  it's not that you can't like -- it's that FB, being coded by drunk monkeys, dones't think that https--blah is the same as http--blah

I seriously don't think there is any way around it for you...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

nend

Facebook isn't the only one. Google search console treats https and http as different sites. I still have half of my URLs on http in the console.

AFAIK, in the OG protocol, url is to be treated as the ID.
Quoteog:url - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "http://www.imdb.com/title/tt0117500/".

So the protocol clearly states to treat this string as the permanent ID. If Facebook followed their protocol to a T, then there is no fix.

spiros

Seems that SMF does not like some of this code

8: Undefined index: canonical_url
...public_html/forum/Themes/citiez_20a/index.template.php
Line: 142


Line 142 has this:
<meta property="og:url" content="' . $context['canonical_url'] . '" />

Posted here about this:
https://www.simplemachines.org/community/index.php?topic=560302.0

Kindred

As stated in the other thread....that error is due to some mistake in your custom coding, since that error does not occur in a baseline smf installation
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

spiros

Well, not exactly my coding, I followed the suggestions in the thread I linked to. :)

Aleksi "Lex" Kilpinen

The like count is just a number - if you have a redirection in place, you haven't lost anything except statistics. I wouldn't really worry about that myself.
But, I think you could do this with something like this for topics

<meta property="og:url" content="http://www.example.com/index.php?topic=';, $context['current_topic'], '" />

Not a clean solution, but should work.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

spiros

Many thanks :)

I tried that and now I get:

8: Undefined index: current_topic
Line: 142

Aleksi "Lex" Kilpinen

Where do you have it? Outside topics it will need an if statement and check that current_topic is actually set.

For example:
if (!empty($context['current_topic']))
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

spiros

File posted here:

https://www.simplemachines.org/community/index.php?topic=560302.msg3972217#msg3972217

Search for:
<meta property="og:url" content="' . $context['canonical_url'] . '" />

Aleksi "Lex" Kilpinen

Yeah, if it's in index.template.php it will need an if statement, because current_topic is only set when you are in a topic.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

spiros

#23
What code do I need to use then? Sorry for being so inept :)

Edit, this appears to have solved it:

if (!empty($context['canonical_url']))
echo '
<meta property="og:url" content="' . $context['canonical_url'] . '" />

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: