Thursday, May 29, 2008

用 AJAX 实现 Blogger 页内评论

之前服务器上有 Java 环境时,一直用一个自己写的 Servlet 作为中间代理来向 Blogger 的评论页面 POST 表单数据,实现页面内的评论操作,后来转挂在朋友的 IIS 服务器下,由于对 ASP 不熟,这一功能就一度取消了。现在购买了新的 Linux PHP 服务器,因此用 PHP 重新写了一个同样功能的中间代理来实现这一功能,并且实现成了 AJAX 的模式。评论内容的读取也一样通过 Blogger Feed 的 JSON 模式读取,因此提交评论后可以立即显示出来,而不用再等待 Blogger 重新生成 HTML 页面并通过 FTP 上传这一漫长的过程。(虽然实际上后台它还是不可避免的执行了这个过程。)

经过多次测试,应该可以用了。关于 Spam 的问题,以前的验证码是直接读取的 Blogger 页面的 Captcha 图片,现在 Google 改变了表单结构以至于程序已经无法自动做这个动作。所以我取消了 Blogger 自己的 Captcha 验证,自己写了个简单的加减法验证,虽然仍然不能完全杜绝 Spam,但已经比几天前测试时裸奔的情况好多了。当时夸张到一个下午一张帖子被贴了 50 多条 Spam 评论。毕竟传说 Google 的 Captcha 也已经被破解了么,同样不能完全杜绝 Spam。 ;-)

另外,Backlink 不显示的问题也修正了。不过,经过前端时间页面恶意代码事件的影响,目前似乎已经没什么 Backlink 了…… :-(

21 comments:

lq said...

这个评论程序很不错啊

lq said...

呵呵

sun said...

我来测试一下效果

felix said...

请问你如何绕过blogger评论界面的captcha验证, 把其它数据成功提交到 comment.do的?

Gregory said...

我在我的 Blogger 设定里面已经将 Captcha 关掉了,而改用这个表单里的简单加减法来 Anti-Spam。

AAA said...

个呵呵呵

植树 said...

这个评论系统是怎么实现的啊?
可否分享一下方法?

Gregory said...

简单的讲就是用 PHP 写了个简单的程序,做这么两件事情:

- 打开 Blogger 上本帖对应的评论页面,分析 HTML 代码,取得每页随机的 Token;
- 将本页的评论内容和取得的 Token 一并 POST 给 Blogger 上处理评论发布的 URL;

之后用 AJAX 的方式通过 Feed 地址获取新的评论内容并更新页面上的数据。

植树 said...

能把那写文件发到我的邮箱吗?izhishu#gmail.com

lll9p said...

这个评论不错

ceshi said...

ceshiyixia

na said...

你的blog真漂亮!这个模板怎么没见过?

测试 said...

测试一下这个评论!

jim kill said...

louis vuitton handbags
burberry scarf
ray ban sunglasses outlet
michael kors
cheap uggs
cheap oakleys
abercrombie fitch
ugg boots
tory burch flats
lv outlet
tods outlet
michael kors handbags
michael kors outlet online
ghd flat iron
coach outlet
coach factory online
prada handbags
lebron 11
canada goose jacket
ray ban outlet
christian louboutin
chanel handbags
coach outlet
polo outlet
michael kors outlet online
ray ban canada
coach factory outlet
20150311huangqihang

mao yun said...

3
michael kors handbags
louis vuitton uk
oakley outlet
nba jerseys wholesale
pandora
fitflop shoes
cheap nhl jerseys
adidas wings
michael kors outlet
replica watches
cheap snapbacks
karen millen sale
coach outlet store online
hollister
nhl jerseys wholesale
air jordan concord
kate spade uk
coach outlet
insanity workout
pandora jewelry
lacoste outlet
tiffany jewelry
michael kors outlet store
cheap mlb jerseys
true religion outlet
tory burch outlet online
soccer jerseys for sale
thomas sabo bracelet
louis vuitton outlet online
valentino sale
asics running shoes
burberry outlet
christian louboutin shoes
hollister clothing
air jordan shoes
giuseppe zanotti sale
longchamp handbags
michael kors handbags
tiffany and co
louboutin shoes
cheap ray ban sunglasses
20150330maoqiuyun

mao yun said...

3
michael kors handbags
louis vuitton uk
oakley outlet
nba jerseys wholesale
pandora
fitflop shoes
cheap nhl jerseys
adidas wings
michael kors outlet
replica watches
cheap snapbacks
karen millen sale
coach outlet store online
hollister
nhl jerseys wholesale
air jordan concord
kate spade uk
coach outlet
insanity workout
pandora jewelry
lacoste outlet
tiffany jewelry
michael kors outlet store
cheap mlb jerseys
true religion outlet
tory burch outlet online
soccer jerseys for sale
thomas sabo bracelet
louis vuitton outlet online
valentino sale
asics running shoes
burberry outlet
christian louboutin shoes
hollister clothing
air jordan shoes
giuseppe zanotti sale
longchamp handbags
michael kors handbags
tiffany and co
louboutin shoes
cheap ray ban sunglasses
20150330maoqiuyun

oakleyses said...

oakley sunglasses, longchamp outlet, ugg boots, chanel handbags, nike air max, longchamp, christian louboutin outlet, michael kors outlet, oakley sunglasses, tiffany and co, replica watches, tory burch outlet, nike air max, ray ban sunglasses, michael kors outlet, louboutin shoes, jordan shoes, louis vuitton outlet, louis vuitton, ray ban sunglasses, longchamp outlet, polo ralph lauren outlet, replica watches, kate spade outlet, oakley sunglasses, polo ralph lauren outlet, cheap oakley sunglasses, ugg boots, nike free, tiffany jewelry, michael kors outlet, uggs on sale, louis vuitton outlet, michael kors, oakley sunglasses, louboutin, louis vuitton, michael kors outlet, ray ban sunglasses, prada handbags, louis vuitton, burberry, burberry outlet online, gucci outlet

oakleyses said...

nike blazer, michael kors, nike free run uk, nike air max, true religion jeans, true religion jeans, air jordan pas cher, nike air max, ralph lauren uk, timberland, air max, nike roshe, tn pas cher, louboutin pas cher, true religion outlet, vans pas cher, coach outlet, hermes, ralph lauren pas cher, nike free, coach purses, michael kors, oakley pas cher, mulberry, hollister pas cher, lacoste pas cher, new balance pas cher, ray ban pas cher, vanessa bruno, burberry, hollister, michael kors, kate spade handbags, coach outlet, abercrombie and fitch, lululemon, coach factory outlet, nike roshe run, north face, nike air max, ray ban uk, michael kors, true religion jeans, converse pas cher, north face, air force, hogan, sac longchamp, longchamp pas cher, sac guess

oakleyses said...

ferragamo shoes, iphone 6s plus cases, babyliss, longchamp, reebok shoes, nike trainers, asics running shoes, oakley, iphone 5s cases, celine handbags, hollister, nfl jerseys, jimmy choo shoes, birkin bag, iphone 6s cases, iphone cases, mcm handbags, bottega veneta, giuseppe zanotti, iphone 6 plus cases, abercrombie and fitch, p90x workout, beats by dre, herve leger, north face outlet, instyler, louboutin, soccer jerseys, lululemon, nike roshe, s5 cases, timberland boots, mac cosmetics, soccer shoes, valentino shoes, insanity workout, vans shoes, hollister, ralph lauren, wedding dresses, ipad cases, chi flat iron, north face outlet, iphone 6 cases, nike air max, ghd, mont blanc, baseball bats, new balance, nike huarache

oakleyses said...

ugg pas cher, vans, moncler, moncler, canada goose, louis vuitton, ugg boots uk, canada goose, toms shoes, doudoune canada goose, moncler, louis vuitton, louis vuitton, ugg australia, juicy couture outlet, moncler, supra shoes, doke gabbana outlet, gucci, karen millen, moncler outlet, hollister, moncler, hollister, canada goose, louis vuitton, ray ban, marc jacobs, pandora jewelry, michael kors outlet online, moncler, swarovski crystal, pandora jewelry, wedding dresses, thomas sabo, moncler, bottes ugg, sac louis vuitton pas cher, nike air max, barbour, barbour jackets, pandora charms, canada goose outlet, canada goose uk, michael kors outlet, converse outlet, links of london, canada goose outlet, pandora charms, canada goose

mmjiaxin said...

cheap jordan shoes
north face outlet store
ralph lauren outlet
ray ban outlet
winter coats
ugg boots
lacoste pas cher
coach outlet
ralph lauren,polo ralph lauren,ralph lauren outlet,ralph lauren italia,ralph lauren sito ufficiale
the north face outlet
snapbacks wholesale
nfl jerseys
coach outlet online
ray-ban sunglasses
pandora outlet
uggs outlet
louis vuitton outlet online
ed hardy clothing
tods outlet
snow boots
mm1205