如何做分享扩展来显示http份额而不是https? [英] How to do the share extension to show the http shares and not the https?

查看:123
本文介绍了如何做分享扩展来显示http份额而不是https?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Facebook对象调试器上有这种情况:

I have this situations on Facebook Object Debugger:

这是一个如果我输入http链接

This one is if I input the http link

这一个用于https链接

and this one for https link

我的joomla扩展的代码是:

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."&amp;href=".$oFlink."&amp;width=".$oFwidth .
                    "&amp;colorscheme=".$oFcolor."&amp;show_faces=".$oFfaces .

                    "&amp;send=".$oFshowSend."&amp;layout=".$oFstyle."&amp;font=".$oFfont."&amp;action=".$oFverb."&amp;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;

    }
}

而.httaccess代码是:

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]

我想做的是分享http链接并从http链接显示共享,在这一刻我可以共享http链接,但是我看到https共享。

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.

在Facebook对象调试器中,您可以看到我查看http链接是否看到https共享,如果我查看https链接,我看到http份额。

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.

如何分享http并查看http份额不是https?

So how to share http and see http shares not https?

推荐答案

我刚检查过您的网站,您网站的主要问题是您正在从http重定向到https,但是,og:url设置为http://版本。检查HTML代码,你会看到这样的:

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"/>

这是令人困惑的Facebook,当您处于http模式时,您应该将og:url作为http,作为https,您处于https模式。

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:我仍然在代码中看到这个...

PS: I still see this in the code...

<link href="/de/" rel="canonical" />

...但我不认为这是有害的。

...but I don't think it's harmful.

这篇关于如何做分享扩展来显示http份额而不是https?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆