问题
I have this situations on Facebook Object Debugger:
This one is if I input the http link
and this one for https link
The code of my joomla extension is:
<?php
/*------------------------------------------------------------------------
# mod_ofblikebutton - Optimized Facebook Like Button
# ------------------------------------------------------------------------
# author: Optimized Sense
# copyright: Copyright (C) 2013 http://www.o-sense.com. All Rights Reserved.
# @license: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.o-sense.com
# Technical Support: http://www.o-sense.com/contact-us/support-inquiries.html
-------------------------------------------------------------------------*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class oFBLikeButton{
function getData(&$params ){
$oFBLinkTitle = 'O-Sense';
$oFBLink = 'http://www.o-sense.com';
//$oFBLinkImg = 'http://www.o-sense.com/osensecopy.png';
//$oFlink = $params->get('olink');///
$oFBLink = JURI::current();
$oFshowSend = $params->get('oshowSend');///
$oFstyle = $params->get('ostyle');
$oFwidth = $params->get('owidth', '400');///
$oFfaces = $params->get('ofaces');///
$oFfont = $params->get('ofont');///
$oFcolor = $params->get('ocolor');///
$oFverb = $params->get('overb');///
$oFsource = $params->get('osource');///
$oFlang = $params->get('olang');///
if($oFfaces == '1'){
$oFfaces = 'true';
}else{
$oFfaces = 'false';
}
if($oFshowSend == '1'){
$oFshowSend = 'true';
}else{
$oFshowSend = 'false';
}
$data ='';
if($oFsource == '1'){
//HTML5
$app = JFactory::getApplication();
$menu = $app->getMenu();
$lang = JFactory::getLanguage();
$fburl = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if($fburl == 'https://www.atlantotec.com/de/' || $fburl == 'https://www.atlantotec.com' || $fburl == 'https://www.atlantotec.com/de')
{
$pageurl = 'http://www.atlantotec.com/de/';
$spageurl = 'https://www.atlantotec.com/de/';
} else {
$finalurls = explode('/',$_SERVER['REQUEST_URI']);
$urls = '';
foreach ($finalurls as $finalurl){
if($finalurl != ''){
$urls .= '/'.$finalurl;
}
}
if ($lang->getTag() == 'it-IT') {
$pageurl = 'http://'.$_SERVER['HTTP_HOST'].$urls;
$spageurl = 'https://'.$_SERVER['HTTP_HOST'].$urls;
} else {
$pageurl = 'http://'.$_SERVER['HTTP_HOST'].$urls;
$spageurl = 'https://'.$_SERVER['HTTP_HOST'].$urls;
}
}
$data = '<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=541263185976160";
fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));</script>';
$data = $data . '<div class="fb-like" data-href="'.$pageurl.'" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>';
/*$url = 'http://api.facebook.com/restserver.php?method=links.getStats&urls='.$pageurl.','.$spageurl;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$retrun = curl_exec($ch);
curl_close($ch);
$oXML = new SimpleXMLElement($retrun);
$total_count=0;
foreach($oXML->link_stat as $link_stat){
//if($total_count != $link_stat->total_count || $total_count ==0)
$total_count += $link_stat->total_count;
}*/
/*$data = '<div class="fb-like" data-href="'.$spageurl.'" data-layout="button" data-action="like" data-show-faces="false" data-share="true"></div>';
$data = '<div id="fb-root"></div><script language="javascript" type="text/javascript">(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/'.$oFlang.'/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));</script>';
$data = $data.'<script language="javascript" type="text/javascript">//<![CDATA[
document.write(\'<div class="fb-like" data-href="'.$pageurl.'" data-width="'.$oFwidth.'" data-colorscheme="'.$oFcolor.'" data-show-faces="'.$oFfaces.'" data-send="'.$oFshowSend.'" data-font="'.$oFfont.'" data-action="'.$oFverb.'" data-layout="button"></div><div class="pluginCountButton pluginCountNum"><div class="pluginCountButtonNub"><s></s><i></i></div><span id="fb-count">'.$total_count.'</span></div> \');
//]]>
</script> <div style="display:none; position: relative; height: 15px; width: 100%; font-size: 10px; color: #808080; font-weight: normal; font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif; line-height: 1.28; text-align: right; direction: ltr;"><a href="'.$pageurl.'" target="_blank" style="color: #808080;"> <img alt="OSense" src="'.$oFBLinkImg.'" style="visibility:visible; zoom: 1; opacity: 1; vertical-align: text-top;" /> '.$oFBLinkTitle.'</a></div>';*/
/*$data = $data.'<script language="javascript" type="text/javascript">//<![CDATA[
document.write(\'<div class="fb-like" data-href="'.$spageurl.'" data-width="'.$oFwidth.'" data-colorscheme="'.$oFcolor.'" data-show-faces="'.$oFfaces.'" data-send="'.$oFshowSend.'" data-font="'.$oFfont.'" data-action="'.$oFverb.'" data-layout="'.$oFstyle.'"></div> \');
//]]>
</script> <div style="display:none; position: relative; height: 15px; width: 100%; font-size: 10px; color: #808080; font-weight: normal; font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif; line-height: 1.28; text-align: right; direction: ltr;"><a href="'.$spageurl.'" target="_blank" style="color: #808080;"> <img alt="OSense" src="'.$oFBLinkImg.'" style="visibility:visible; zoom: 1; opacity: 1; vertical-align: text-top;" /> '.$oFBLinkTitle.'</a></div>';*/
}else if($oFsource == '2'){
//XFBML
$data = '<div id="fb-root"></div><script language="javascript" type="text/javascript">(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/'.$oFlang.'/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));</script>';
$data = $data.'<script language="javascript" type="text/javascript">//<![CDATA[
document.write(\'<fb:like href="'.$oFlink.'" width="'.$oFwidth.'" colorscheme="'.$oFcolor.'" show_faces="'.$oFfaces.'" font="'.$oFfont.'" send="'.$oFshowSend.'" layout="'.$oFstyle.'" action="'.$oFverb.'"></fb:like> \');
//]]>
</script> <div style="display:none; position: relative; height: 15px; width: 100%; font-size: 10px; color: #808080; font-weight: normal; font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif; line-height: 1.28; text-align: right; direction: ltr;"><a href="'.$oFBLink.'" target="_blank" style="color: #808080;"> <img alt="OSense" src="'.$oFBLinkImg.'" style="visibility:visible; zoom: 1; opacity: 1; vertical-align: text-top;" /> '.$oFBLinkTitle.'</a></div>';
}else {
//iFrame
$oFsource ="http://www.facebook.com/plugins/like.php?locale=".$oFlang."&href=".$oFlink."&width=".$oFwidth .
"&colorscheme=".$oFcolor."&show_faces=".$oFfaces .
"&send=".$oFshowSend."&layout=".$oFstyle."&font=".$oFfont."&action=".$oFverb."&height=26";
$data = '<iframe src="'.$oFsource.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$oFwidth.'px; height:26px;" allowTransparency="true"></iframe> <div style="display:none; position: relative; height: 15px; width: 100%; font-size: 10px; color: #808080; font-weight: normal; font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif; line-height: 1.28; text-align: right; direction: ltr;"><a href="'.$oFBLink.'" target="_blank" style="color: #808080;"> <img alt="OSense" src="'.$oFBLinkImg.'" style="visibility:visible; zoom: 1; opacity: 1; vertical-align: text-top;" /> '.$oFBLinkTitle.'</a></div>';
}
return $data;
}
}
And the .httaccess code is:
RewriteEngine on
Options +FollowSymLinks
#
# HTTPS Redirect
RewriteCond %{HTTP_HOST} !^www\.atlantotec\.com$
RewriteRule ^(.*)$ https://www.atlantotec.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^(.*)=it$ http://www.atlantotec.com/it/$1 [R,NC]
RewriteRule ^(.*)=de$ http://www.atlantotec.com/de/$1 [R,NC]
RewriteRule ^(.*)=en$ http://www.atlantotec.com/en/$1 [R,NC]
What I want to do is to share http link and to show the shares from http link, in this moment I can share the http link, but I see the https shares.
In Facebook Object Debugger you can see if I check the http link I see the https shares, if I check the https link I see the http shares.
I deleted already the canonical tag but doesn't work if you think that is an option.
So how to share http and see http shares not https?
回答1:
I just checked your website, and the main issue with your website is that you are redirecting from http to https, but, the og:url is set to the http:// version. Check the HTML code and you will see this:
<meta property="og:url" content="http://www.[yourdomain].com"/>
This is confusing Facebook, you should have the og:url as http when you are in http mode, and as https whe you are in https mode.
PS: I still see this in the code...
<link href="/de/" rel="canonical" />
...but I don't think it's harmful.
来源:https://stackoverflow.com/questions/34141378/how-to-do-the-share-extension-to-show-the-http-shares-and-not-the-https