Ionic APP中的Disqus [英] Disqus in Ionic APP

查看:152
本文介绍了Ionic APP中的Disqus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的离子应用程序中实现disqus提交。我知道我必须在域中托管它,我认为我已经正确配置了它。欢迎任何帮助

I am trying to implement disqus commments in my ionic app. I know I have to host it on the domain its setup for which I believe I have configured correctly. Any assistance will be welcomed

以下是我的app.js中针对离子应用程序的代码

Here is the code in my app.js for the ionic app

$scope.showComments = function () {
    $scope.currentView = "comments";
    //loadComments(params["shortname"], params["url"], params["title"], params["identifier"]);
    //

    var disqus_title = "Venue 1";
    var disqus_identifier = '/venue/' + $stateParams.id;
    var disqus_url = 'liverpool.li/venue/' + $stateParams.id;
    var url = "http://liverpool.li/app/disqus.html?";
    $scope.url = url + "shortname=liverpoolli&url=" + encodeURIComponent(disqus_url) +
    "&title=" + encodeURIComponent(disqus_title) + "&identifier=" + encodeURIComponent(disqus_identifier);
    $scope.url = $sce.trustAsResourceUrl($scope.url);
};

$scope.$on("$destroy", function () {
    if ($scope.lastScriptElm && $scope.lastScriptElm.parentNode) {
        $scope.lastScriptElm.parentNode.removeChild($scope.lastScriptElm);
        $scope.lastScriptElm = null;
    }
});

它指向的网页(disqus.html)位于我的域名

And the page it points to (disqus.html) located on my domain

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<body>
<div id="disqus_thread"></div>
<script type="text/javascript">
    var params;
    var disqus_url;
    var disqus_title;
    var disqus_shortname;
    var disqus_identifier;

    window.onload = function () {
        var match,
            pattern = /\+/g,
            search = /([^&=]+)=?([^&]*)/g,
            decode = function (s) { return decodeURIComponent(s.replace(pattern, " ")); },
            query = window.location.search.substring(1);

        params = {};
        while (match = search.exec(query))
           params[decode(match[1])] = decode(match[2]);

        if (params["shortname"] === undefined || params["url"] === undefined || params["title"] === undefined) {
            alert("Required arguments missing");
        }
        else {
            loadComments(params["shortname"], params["url"], params["title"], params["identifier"]);
        }
    };

    function loadComments(shortname, url, title, identifier) {
        disqus_url = url;
        disqus_title = title;
        disqus_shortname = shortname;

        if (identifier !== undefined)
            disqus_identifier = identifier;
        else
            disqus_identifier = "";

        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = false;
            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    }
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
</body>
</html>

我收到以下错误


我们无法加载disqus。如果您是版主,请参阅我们的
故障排除指南。

we were unable to load disqus. if you are a moderator please see our troubleshooting guide.


推荐答案

它看起来就像你几乎在那里。我看到的唯一问题是 disqus_url 变量还必须包含有效的协议。请尝试使用此行:

It looks like you're almost there. The only issue I see is the disqus_url variable must also include the protocol to be valid. Try using this line instead:

var disqus_url ='http://liverpool.li/venue/'+ $ stateParams.id;

这篇关于Ionic APP中的Disqus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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