【问题标题】:How to fix problem with gif sharing facebook sharer.php如何解决 gif 共享 facebook sharer.php 的问题
【发布时间】:2020-06-28 01:32:28
【问题描述】:

我在分享时对 facebook 分享器有疑问,生成文件路径并在 facebook 上分享准备好在用户时间轴上显示的本机 gif。 我当然在使用

.qa_html ($ this-> content ['description']).

这是最终 .gif 文件的目的地

.qa_html ($ shareurl). 是出版物的网址,是我希望用户在点击左下角 Facebook 上的网站按钮以及下图中的网站按钮时被重定向到的网址。



有人能告诉我如何通过在用户的时间轴上显示原生 gif 并根据此信息显示发布地址,从而将分享更改为 facebook 吗?


我的元变量

$this->output('<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />');
        $this->head_links();
        if ($this->template == 'question' && strpos(qa_get_state(), 'edit')===false ) {
                $pagetitle=strlen($this->request) ? strip_tags($this->content['title']) : '';
                $headtitle=(strlen($pagetitle) ? ($pagetitle.'') : '');

                $this->output('<meta property="og:url" content="'.qa_html( $this->content['canonical'] ).'" />');
                $this->output('<meta property="og:type" content="article" />');
                $this->output('<meta property="og:title" content="'.qa_html( $headtitle ).'" />');
                $this->output('<meta property="og:description" content="Click To Watch" />');
                $this->output('<meta property="og:image" content="'.qa_html( $this->content['description'] ).'"/>');
                $this->output('<meta name="twitter:card" content="summary_large_image">');
                $this->output('<meta name="twitter:title" content="'.qa_html( $headtitle ).'">');
                $this->output('<meta name="twitter:description" content="'.qa_html( $headtitle ).'">');
                $this->output('<meta name="twitter:image" content="'.qa_html( $this->content['description'] ).'">');
                $this->output('<meta itemprop="description" content="click to watch">');
                $this->output('<meta itemprop="image" content="'.qa_html( $this->content['description'] ).'">');
                $this->output('<link rel="image_src" type="image/jpeg" href="'.qa_html( $this->content['description'] ).'" />');
        }

我正在尝试进行调整,以便当用户单击 facebook 内 gif 中出现的左下角按钮时,他将被重定向到发布页面。 pinterest 函数使用以下参数,效果很好。

$this->output('<a class="share-badge pinshare" href="//www.pinterest.com/pin/create/button/?url='.qa_html( $shareurl ).'&amp;media='.qa_html( $this->content['description'] ).'&amp;description="

我的问题是如何使 pinterest 代码适应 facebook 共享代码,以便它适用于 facebook 共享,当用户点击网站地址时,在用户的时间轴上显示本机 gif 将被重定向到相关出版物。就像在 pinterest 上一样

PS:.qa_html ($ this-&gt; content ['description']).是文件的最终地址

ps:pinterest 工作正常 有人可以帮我解决这个问题吗?提前致谢。欢迎任何帮助。

完整代码主题 https://pastebin.com/mXNfewVW


facebook 分享者和社交功能代码:(代码已更改)

   function socialshare()
    {
        $pagetitle=strlen($this->request) ? strip_tags($this->content['title']) : '';
        $headtitle=(strlen($pagetitle) ? ($pagetitle) : '');
        $shareurl= qa_path_html(qa_q_request($this->content['q_view']['raw']['postid'], $this->content['q_view']['raw']['title']), null, qa_opt('site_url'));

        $this->output('<div class="share-overlay">');
        $this->output('<a  title="Share on Facebook" href="https://www.facebook.com/sharer/sharer.php?u='.qa_html( $this->content['description'] ).'" target="_blank" rel="nofollow" onclick="javascript:window.open(this.href, \'_blank\', \'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600\');return false;">');
        $this->output('<i class="fab fa-facebook"></i></a>');
        $this->output('<a class="share-badge twitter" href="http://twitter.com/share?text='.qa_html( $headtitle ).'&amp;url='.qa_html( $shareurl ).'" title="Share on Twitter" rel="nofollow" target="_blank" onclick="avascript:window.open(this.href, \'_blank\', \'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600\');return false;"><i class="fab fa-twitter"></i></a>');

            $this->output('<a class="share-badge pinshare" href="//www.pinterest.com/pin/create/button/?url='.qa_html( $shareurl ).'&amp;media='.qa_html( $this->content['description'] ).'&amp;description=" title="Pin It" target="_blank" onclick="javascript:window.open(this.href, \'\', \'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600\');return false;"><i class="fab fa-pinterest"></i></a>');

        $this->output('</div>');
    }

【问题讨论】:

    标签: php facebook


    【解决方案1】:

    你可以很容易地通过添加这个来做到这一点

    $this->output('<meta property="og:url" content="'.$this->content['description'].'" />');
    

    由于最后的 CID,您将遇到无法正确调用 giphy 的问题,因此您需要让它从 filename.gif 之后的任何内容中删除数据。

    您可以在这里轻松地做到这一点:

    `

    $re = '/(?<=gif).*/';
    $str = $this->content['description'];
    $subst = '';
    $result = preg_replace($re, $subst, $str);`
    $this->output('<meta property="og:url" content="'.$result.'" />');
    
    Place this code in /root/king-theme/YOURTHEME/king-theme.php and above the $this->output('<meta property="og:type" content="article" />');
    

    字体:dafitime https://kingsupport.kingthemes.net/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-08
      • 2016-08-10
      • 1970-01-01
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多