Giter VIP home page Giter VIP logo

disqus-php-api's People

Contributors

fooleap avatar indes avatar jefferywang avatar poplite avatar quericy avatar raincal avatar wzkres avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disqus-php-api's Issues

建议将暂存的数据存储在数据库中

disqus-php-api 暂存的数据一般存储在/tmp目录里,因此一旦机器重启,所有的数据都丢失了(特别是匿名用户的邮箱地址)。

能否存储在一个 SQL 数据库中,或者/tmp目录以外的地方,防止重启后数据丢失?

Handler thread creation error handling

When creating a thread failed because the target thread already exists, the API will still return 200 OK. The front end needs to handle this error
{"code":2,"response":"A thread already exists with link, 'http://www.jasongj.com/java/concurrenthashmap/'"}

查询字符串的访问链接会创建新的 thread

您好!非常棒的工作,很早就用在我的网站上了,https://esl.hohoweiya.xyz/

最近我发现了个问题,我在 disqus 后台管理评论时,发现带有查询字符串的访问链接会创建新的 thread,比如

Selection_2501

虽然在带查询字符串的网页上仍然能够成功加载 https://esl.hohoweiya.xyz/04-Linear-Methods-for-Classification/4.2-Linear-Regression-of-an-Indicator-Matrix/index.html 下的评论。

基本信息

目前我使用的是最新的第二个版本 88dd45a ,建站工具为 mkdocs,配置信息为

<div id="comment"></div>
<script>
    var disq = new iDisqus('comment', {
    forum: 'esl-hohoweiya-xyz',
    api: 'https://api.hohoweiya.xyz/disqus-php-api/api/',
    site: 'https://esl.hohoweiya.xyz',
    mode: 1,
    timeout: 3000,
    init: true,
    relatedType: "popular",
    url: "{{ page.canonical_url | replace(config.site_url, "") }}"
});
</script>

其中 url 项会除掉查询字符串,如上面网页无论是否存在查询字符串都是

url: "/04-Linear-Methods-for-Classification/4.2-Linear-Regression-of-an-Indicator-Matrix/index.html"

一些尝试

  1. 如果直接使用 disqus 的 universal code,https://disqus.com/admin/install/platforms/universalcode/ ,对于带查询字符串的网页也不会创建新的 thread
  2. 一开始怀疑是触发了 create thread 的操作,
    postAjax(_.opts.api + '/createthread.php', postData, function (resp) {

    但是通过 chrome devtool 设置断点并未发现相应语句有被执行
  3. 怀疑是当加载 disqus 时,设置的 identifier 等变量因为某种原因被清了,使得再次加载时,disqus 自动为当前 url 建立 thread。(但是对 javascript 的了解非常少,可能这个猜测有点幼稚)

想请教下可能的原因及处理方案,谢谢!

反引号就不需要加号了。

`
<li class="related-item">
    <a class="related-item-link" href="${item.link}" title="${item.title}">
        <div class="related-item-title">${item.title}</div>
        <div class="related-item-desc">${item.posts}条评论<span class="related-item-bullet"> • </span>
            <time class="related-item-time" datetime="${item.createdAt}"></time>
        </div>
    </a>
    <a class="related-item-link" href="${item.link}?#comment-${item.topPost.id}" title="${item.topPost.raw_message}">
        <div class="related-item-post">
            <div class="related-item-avatar">
                <img src="${item.topPost.avatar}" />
            </div>
            <div class="related-item-main"> <span class="related-item-name">${item.topPost.name}</s>
                            <span class="related-item-message">${item.topPost.raw_message}</span>

            </div>
        </div>
    </a>
</li>
`

创建 Thread 的安全问题

创建 Thread 时没有设置任何验证,允许任何人直接调用createthread.php创建任意 Thread。

另外,在部署有评论框的网页 URL 后添加任意参数(如?123),就能调起创建 Thread 窗口:(貌似用网页 URL 当 Identifier 都存在类似问题)
default

建议:在服务端上检查创建 Thread 的用户身份,仅允许管理员创建 Thread,否则返回错误。

heroku上成功部署,也能加载demo,但是在hexo网站上一直显示“正在初始化”的动画

昨天好不容易成功在hexo网站(https://ajioy.cn/thinking/why-do-i-create-a-personal-website/) 上成功显示过一次disqus,因为有多余的thread,所以重新来过了,奇怪的是怎么做都没用了,尝试五六回都是如此,一直显示“正在初始化”,只好过来请教大神,如您空了还望帮忙看下是哪个环节出了问题。

前端部分disqusapi.pug

if theme.disqusapi && theme.disqusapi.enable
  link(rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ajioy/CDN/js/iDisqus.min.css")
  script(src='https://cdn.jsdelivr.net/gh/ajioy/CDN/js/iDisqus.min.js')
  #comment
  script.
    var disq = new iDisqus('comment', {
      forum: 'ajioy.cn',
      api: 'https://ajioycn.herokuapp.com/api/',
      site: 'https://ajioy.cn',
      mode: 1,
      timeout: 3000,
      init: true,
      emojiPreview: true
    });
    disq.count();

后端heroku demo(https://ajioycn.herokuapp.com/dist/)

Nginx上一直显示“正在初始化”

本地的的测试环境成功,上传到VPS就不行
测试路径:/disqus-php-api-master/dist/
请问怎样设置Nginx的伪静态问题呢

本地测试环境:XAMPP+apache
VPS环境:宝塔面板+Nginx 1.17

匿名头像 `noavatar92.png` 404 Not Found

刚刚发现加载不了匿名头像

https://a.disquscdn.com/1572395070/images/noavatar92.png 

但是记得昨天还是可以的。另外发现如果直接访问

https://a.disquscdn.com/images/noavatar92.png

是可以得到匿名头像的。所以很好奇 1572395070 是指什么,因为查了几个匿名头像,都是跟了这串数字。
现在加载不了不知道是不是暂时的,还是因为发生了什么改变?如果直接不用 1572395070 来返回匿名头像,是否可以?

关于-This application cannot create posts on the chosen forum

您好,我在测试postcomment.php提交评论的时候,出现了如下的返回:

{"code":12,"thread":null,"response":"This application cannot create posts on the chosen forum"}

在单独测试disqus api对应的posts/create时也遇到了同样的问题,请问你有遇到过吗?

无法显示被隐藏的回复

如图,原生评论框现在会隐藏超过一定长度楼层中的部分回复(显示更多回复):

image

disqus-php-api的评论框显示不了这些被隐藏的回复:

image

listPostsThreadedAPI的响应中,有个hasMore参数指明该评论下是否有回复被隐藏。

image

获取隐藏回复的内容需要用到getDescendantsAPI:

https://disqus.com/api/3.0/posts/getDescendants?limit=50&order=desc&post=4392256230&start_post=&cursor=&api_key=E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F

4392256230即是上图中的id参数。

加载错误

您好~ 我的网站出现了如下错误,大概4-5个类似的这样
Uncaught SyntaxError: Unexpected token 没 in JSON at position 0
at JSON.parse ()

完整的代码是

Uncaught SyntaxError: Unexpected token 没 in JSON at position 0
at JSON.parse (<anonymous>)
at iDisqus.js:193
at XMLHttpRequest.a.onreadystatechange (iDisqus.js:34)
(anonymous) @ iDisqus.js:193
a.onreadystatechange @ iDisqus.js:34
XMLHttpRequest.send (async)
u @ iDisqus.js:39
autologin @ iDisqus.js:192
v @ iDisqus.js:122
h.init @ iDisqus.js:587
h @ iDisqus.js:419
(anonymous) @ (index):249

邮箱验证有点问题,匿名评论一直要审核

1、[email protected] 类似这种样式的邮箱会提示“请正确填写邮箱。”,验证不通过

2、我测试匿名评论每次都要审核,DISQUS_APPROVED已经设置为true了,disqus里面的相应设置也是None。
查看postcomment.php找到“父评是已登录用户”那块代码发现貌似对父评论是登录的非匿名用户会改成需要审核,但是我在页面直接评论应该不存在父评论吧?目前我暂时注释掉那几行判断代码后就不需要审核了。

审核的问题是我在哪里设置错了吗?

建议

建议表情弹出可以选择空白位置消失。

url中带有加号时不能获取评论

从disqus后台看link中带有加号,创建的thread是没有问题,但是getcomment.php返回的thread中加号变成了空格,提示没有这个thread。再次创建会报已存在的错误。

gravatar不显示

不仅是我的博客,博主你的博客也是不显示gravatar的,我发现是因为gravatar链接后面跟了disqus头像的参数导致跳转到noavatar,这个怎么解决呢?

增加设置只显示gravatar而不是disqus头像可能好一点吧?

换了授权登录版本后评论不了

换了授权登录版本后,按照说明去申请和填好apikey了,其他好像都没什么问题,就是评论不了。
简易评论框点登录按钮也能成功登录,但就是发不了评论。
浏览器调试发现postcomment.php返回:
{"code":5,"response":"Invalid API key"}

apikey也仔细检查了几遍,没有发现问题出在哪

提交失败,请稍后重试,错误代码:12

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <title>Disqus PHP API 示例</title>
        <style>
            body{
                max-width: 640px;
                width: 100%;
                margin: 0 auto;
                overflow-x: hidden;
                font-size: 13px;
            }
            a{
                color: #0095dd;
            }
        </style>
    <link href="iDisqus.min.css" rel="stylesheet"><script type="text/javascript" src="iDisqus.min.js"></script></head>
    <body>
        <p>本页共有 <span data-disqus-url="https://infinitescript.com/contact/"></span> 条评论,
        项目地址:<a href="https://github.com/fooleap/disqus-php-api" target="_blank">https://github.com/fooleap/disqus-php-api</a></p>
        <div id="comment"></div>
        <script>
            var disq = new iDisqus('comment', {
                forum: 'zjhzxhz',
                site: 'https://infinitescript.com',
                api: 'https://disqus.infinitescript.com',
                url: 'https://infinitescript.com/contact/',
                mode: 2,
                timeout: 3000,
                init: true,
                emojiPreview: true
            });
            disq.count();
        </script>
    </body>
</html>

当匿名提交评论时,提示“提交失败,请稍后重试,错误代码:12”。
错误代码12给出的信息是:You cannot set 'state' because you are not a moderator of this thread.

Guest Commenting已开启。

符号待完善

例如“*”、“#”一类,在PC端和移动(Android)端均无法显示,只能在disqus的反馈邮件中查看。影响体验,望改善,谢谢!

failed to open stream

<br />
<b>Warning</b>:  file_get_contents(/tmp/session-aimuz.json): failed to open stream: No such file or directory in <b>/var/www/html/disqus/init.php</b> on line <b>40</b><br />
<br />
<b>Warning</b>:  file_get_contents(/tmp/session-aimuz.json): failed to open stream: No such file or directory in <b>/var/www/html/disqus/init.php</b> on line <b>41</b><br />
<br />
<b>Warning</b>:  Creating default object from empty value in <b>/var/www/html/disqus/getcomments.php</b> on line <b>44</b><br />
{"auth":false,"code":null,"cursor":null,"link":"https:\/\/disqus.com\/home\/discussion\/aimuz\/\/?l=zh","posts":null,"response":[],"thread":null}

我用的是 php7 ,构建在docker

评论不了

最近怎么评论不了了

如图,评论后不是实体而且有点虚的感觉,按F5后评论就消失了.
做过测试,就是如果在网址一栏填写了没有http开头的网址就会这样子。

一直转圈,显示正在初始化,右键检查错误iDisqus.min.js:11

https://zhubin.org/disqus/
右键检查错误内容:
Egde

iDisqus.min.js:11 Uncaught TypeError: Cannot set property 'outerHTML' of null
    at iDisqus.min.js:11
    at XMLHttpRequest.a.onreadystatechange (iDisqus.min.js:11)
(匿名) @ iDisqus.min.js:11
a.onreadystatechange @ iDisqus.min.js:11

Firefox

Uncaught TypeError: o.dom.querySelector(...) is null
    threadInit https://api.zhubin.org/disqus/iDisqus.min.js:11
    onreadystatechange https://api.zhubin.org/disqus/iDisqus.min.js:11
    u https://api.zhubin.org/disqus/iDisqus.min.js:11
    threadInit https://api.zhubin.org/disqus/iDisqus.min.js:11
    init https://api.zhubin.org/disqus/iDisqus.min.js:11
    h https://api.zhubin.org/disqus/iDisqus.min.js:11
    <anonymous> https://zhubin.org/disqus/:11
iDisqus.min.js:11:47466

在虚拟主机和 VPS 上都安装了,主机不行就换了VPS,权限也改成 777,报错看着都差不多,错误11。
点 Callback URL 可以跳转,threadsDetails.php?ident=/disqus/&link=/disqus/ 也能看到评论个数,感觉账号配置没错……
不知道是哪里出问题了?

可考虑加上删除评论

删除评论只能通过disqus后台删除。能不能直接在评论“回复”后加上“删除”,也方便其他留言者。谢谢~

emoji表情在PJAX下加载出错

这是F12控制台的信息

Uncaught ReferenceError: emojify is not defined
    at HTMLDocument.eval (eval at globalEval (jquery.js:328), <anonymous>:1:15)
    at j (jquery.js:3099)
    at Object.add [as done] (jquery.js:3145)
    at n.fn.init.n.fn.ready (jquery.js:3378)
    at new n.fn.init (jquery.js:2821)
    at n (jquery.js:76)
    at eval (eval at globalEval (jquery.js:328), <anonymous>:1:2)
    at eval (<anonymous>)
    at Function.globalEval (jquery.js:328)
    at n.fn.init.domManip (jquery.js:5435)

Can't load some threads if the site supports both HTTP and HTTPS

The current api and js have problem in the following two scenarios:

  • The site supports both HTTP and HTTPS
  • The site uses HTTP before, then switch to HTTPS, or vice versa

It turns out that the url is not a good choice as the filter to get the thread, because that url changes in different protocols.(http://.... and https://....)

I suggest using identifier instead.
-$thread = 'link:'.$website.$_GET['link'];
+$thread = 'ident:'.$_GET['ident'];
The js client need to be modified accordingly too.

If you also agree it's a good solution, I'll send a pull request to fix it.

邮件提醒的问题

你好,请问邮件回复提醒有相关的日志可以查看吗?我这里基本上没有成功过,config.php 中已经对应配置,想知道是不是 VPS 的原因。

添加now.json缺失的文件

你好,使用了修改之后的now.json仍然有一些文件缺失,所以我又做了略微的修改

"builds": [
    { "src": "api/*.php", "use": "@now/php" },
    { "src": "api/PHPMailer/*.php", "use": "@now/php" },
    { "src": "api/emojione/*.php", "use": "@now/php" },
    { "src": "api/emojione/src/*.php", "use": "@now/php" },
    { "src": "dist/*", "use": "@now/static" }
  ]

现在可以正确部署了。

但是缓存的持久化似乎仍然不行,导致邮件之类的功能工作不正常,这可能是由于写本地文件系统在now.sh, heroku之类的平台上无法持久化导致的,现在看起来还不能直接解决这个问题。

或许解决的办法只有将缓存持久化到第三方文件系统或者数据库了。

jwt.php 在 PHP5 下报错

$ php -v
PHP 5.5.9-1ubuntu4.24 (cli) (built: Mar 16 2018 12:41:43)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

$ php jwt.php
PHP Fatal error:  Default value for parameters with a class type hint can only be NULL in /xxx/jwt.php on line 60

换用 PHP7 之后正常。

出错原因:https://stackoverflow.com/questions/8522984/type-hinting-default-parameters/8523033#8523033

无法正确在now.json部署

首先,如果我直接执行now命令,它会报下面这个错误

You defined 1 build that did not match any source files (please ensure they are NOT defined in .nowignore)

所以修改了now.json文件变成如下形式

{
  "version": 2,
  "builds": [{ "src": "*/*.php", "use": "@now/php" }]
}

重新执行now是可以成功部署的,但是访问<url>/api/login.php时提示没有权限。

由于同样的配置文件,在我自己的主机上能正确部署,因此配置文件应当是没有问题的。我同样修改了disqus设置中对应的回调地址,但问题依旧。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.