fooleap / disqus-php-api Goto Github PK
View Code? Open in Web Editor NEW利用 PHP cURL 转发 Disqus API 请求
License: MIT License
利用 PHP cURL 转发 Disqus API 请求
License: MIT License
disqus-php-api 暂存的数据一般存储在/tmp
目录里,因此一旦机器重启,所有的数据都丢失了(特别是匿名用户的邮箱地址)。
能否存储在一个 SQL 数据库中,或者/tmp
目录以外的地方,防止重启后数据丢失?
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/'"}
什么情况下会触发评论通知?就是邮件通知
您好!非常棒的工作,很早就用在我的网站上了,https://esl.hohoweiya.xyz/
最近我发现了个问题,我在 disqus 后台管理评论时,发现带有查询字符串的访问链接会创建新的 thread,比如
虽然在带查询字符串的网页上仍然能够成功加载 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"
Line 1902 in 69a4c39
想请教下可能的原因及处理方案,谢谢!
`
<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>
`
提示:
Disqus
Invalid Request: Invalid parameter: redirect_uri (should match predefined callback URI)
请问这是什么情况?如何解决?谢谢。
创建 Thread 时没有设置任何验证,允许任何人直接调用createthread.php
创建任意 Thread。
另外,在部署有评论框的网页 URL 后添加任意参数(如?123
),就能调起创建 Thread 窗口:(貌似用网页 URL 当 Identifier 都存在类似问题)
建议:在服务端上检查创建 Thread 的用户身份,仅允许管理员创建 Thread,否则返回错误。
昨天好不容易成功在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/)
本地的的测试环境成功,上传到VPS就不行
测试路径:/disqus-php-api-master/dist/
请问怎样设置Nginx的伪静态问题呢
本地测试环境:XAMPP+apache
VPS环境:宝塔面板+Nginx 1.17
开发者你好,
今天在尝试适配now.sh的v2规则时,发现now.sh有一个build-sources的限制。在一次部署中,不允许超过32个资源文件(Free plan),请问能否精简php文件数;或者,若只需要简单的评论功能,能否指明哪些php是非必须的?
谢谢!
关于限制: https://zeit.co/docs/v2/deployments/builds/#build-sources-limit
Line 194 in 8ce2a5b
get_ip
函数中的正则表达式无法匹配IPv6地址:
$ip = "2001:4860:4860::8888";
echo preg_regex('/[\d\.]+/', $ip); // 输出:2001
IPv6访客留言时出错:
P.S. 双栈VPS
一直在加载中。。。
刚刚发现加载不了匿名头像
https://a.disquscdn.com/1572395070/images/noavatar92.png
但是记得昨天还是可以的。另外发现如果直接访问
https://a.disquscdn.com/images/noavatar92.png
是可以得到匿名头像的。所以很好奇 1572395070
是指什么,因为查了几个匿名头像,都是跟了这串数字。
现在加载不了不知道是不是暂时的,还是因为发生了什么改变?如果直接不用 1572395070
来返回匿名头像,是否可以?
您好,我在测试postcomment.php提交评论的时候,出现了如下的返回:
{"code":12,"thread":null,"response":"This application cannot create posts on the chosen forum"}
在单独测试disqus api对应的posts/create
时也遇到了同样的问题,请问你有遇到过吗?
如图,原生评论框现在会隐藏超过一定长度楼层中的部分回复(显示更多回复):
disqus-php-api
的评论框显示不了这些被隐藏的回复:
listPostsThreaded
API的响应中,有个hasMore
参数指明该评论下是否有回复被隐藏。
获取隐藏回复的内容需要用到getDescendants
API:
https://disqus.com/api/3.0/posts/getDescendants?limit=50&order=desc&post=4392256230&start_post=&cursor=&api_key=E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F
4392256230
即是上图中的id
参数。
我在本地测试能通过, 可是把项目移到VPS上之后, 每次都是一直停在正在加载评论。请问这是什么原因?
现象:无法登录到disqus,提示Invalid Request: Invalid parameter: redirect_uri (should match predefined callback URI)
博客地址:https://ipa.moe/
后台设置的callback url为https://ytiihstewszpoovcsaqeb.disqus.soasurs.net/disqus/login.php
请问这是什么原因?应当如何修正?谢谢
您好~ 我的网站出现了如下错误,大概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
App 设置方面一定要按照你黄色标记的那样写吗?
1、[email protected] 类似这种样式的邮箱会提示“请正确填写邮箱。”,验证不通过
2、我测试匿名评论每次都要审核,DISQUS_APPROVED已经设置为true了,disqus里面的相应设置也是None。
查看postcomment.php找到“父评是已登录用户”那块代码发现貌似对父评论是登录的非匿名用户会改成需要审核,但是我在页面直接评论应该不存在父评论吧?目前我暂时注释掉那几行判断代码后就不需要审核了。
审核的问题是我在哪里设置错了吗?
建议表情弹出可以选择空白位置消失。
从disqus后台看link中带有加号,创建的thread是没有问题,但是getcomment.php返回的thread中加号变成了空格,提示没有这个thread。再次创建会报已存在的错误。
不仅是我的博客,博主你的博客也是不显示gravatar的,我发现是因为gravatar链接后面跟了disqus头像的参数导致跳转到noavatar,这个怎么解决呢?
增加设置只显示gravatar而不是disqus头像可能好一点吧?
node应该用哪个版本?
换了授权登录版本后,按照说明去申请和填好apikey了,其他好像都没什么问题,就是评论不了。
简易评论框点登录按钮也能成功登录,但就是发不了评论。
浏览器调试发现postcomment.php返回:
{"code":5,"response":"Invalid API key"}
apikey也仔细检查了几遍,没有发现问题出在哪
有没有办法判断页面滚动到哪里然后自动加载?
<!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的反馈邮件中查看。影响体验,望改善,谢谢!
<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
Access to XMLHttpRequest at 'https://disqus.OCERSEA-SERVER.com/user.php' from origin 'https://blog.DOMESTIC-CERVER.com' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
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后台删除。能不能直接在评论“回复”后加上“删除”,也方便其他留言者。谢谢~
我最初设了相关的信息;
后来没有设,感觉用起来没有区别?
这是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)
The current api and js have problem in the following two scenarios:
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 的原因。
RT
你好,使用了修改之后的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
之类的平台上无法持久化导致的,现在看起来还不能直接解决这个问题。
或许解决的办法只有将缓存持久化到第三方文件系统或者数据库了。
$ 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
命令,它会报下面这个错误
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设置中对应的回调地址,但问题依旧。
注意到阿里云的函数计算提供了PHP的HTTP Trigger环境
这样可以直接使用香港的区域来部署
我不是很会PHP 也有看到Node.JS的版本也不会= =
太难了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.