Monday, September 21, 2009

用 Feed 实现 Blogger 分页

使用 Blogger 建博客,一个很不爽的问题是在首页下方没有分页功能,这会直接导致有兴趣的读者没有办法方便的翻阅以前的旧帖子;而 Blogger 提供的模板,无论是老的 Template,还是新的 Layout,都没有相关的标签来实现这个功能,因此要加上这个功能,就只能继续 hack 了。

这两天利用 Blogger 的完整帖子的 Feed,配合 PHP 实现了这个功能。思路为:
  • 读取原始的 index.html,把帖子的部分去掉,也就是 <Blogger>...</Blogger> 这段内容
  • 读取以下 Feed 地址,解析出文章的日期、时间、标题、正文、标签等,按照原来模板的格式,用 PHP 输出到原来 index.html 放文章的地方
    http://www.blogger.com/feeds/[blogId]/posts/full?max-results=[step]&start-index=[startIndex]&orderby=published
  • 根据当前页码以及总帖数计算分页,在页面底部添加分页链接
  • 如果有条件,可以利用 .htaccess 文件,将分页的 URL 由原来的
    xxx.php?page=x
    形式替换成对搜索引擎更友好的
    /index/x
    形式

如此一来,就可以在自己不存储任何文章数据的情况下,实现分页功能。当然,直到目前,以上的 Feed 地址仍然是被墙的,需要翻墙或者使用 HTTP 代理才能成功地获取内容。

40 comments:

kira said...

请问你博客首页的分页功能也是这样实现的吗?
没有架设自己服务器的blogspot.com博客该怎么修改才能实现分页效果呢?

kira said...

突然发现你的评论貌似采用了Ajax,请问这个是怎么实现的?blogspot这样的博客也可以吗?

Gregory said...

这篇描述的就是如何在首页上实现的分页;至于 blogspot.com 上分页,也可以用类似的办法实现,只是不需要那么麻烦,直接用 JavaScript 读取 Feed 的内容,解析后再用 AJAX 的思路显示到页面上就可以了。

AJAX 的页内评论,简单来讲是把评论表单的内容通过 PHP 程序直接 POST 给 Blogger 接收评论的 URL,然后再通过评论的 Feed 地址取得新的评论列表,再更新到当前页面上。Blogspot 上的 Blog 上面要这样做,没有办法写 PHP 程序,因此只能自己写 JavaScript 来实现将评论内容 POST 到 Blogger。

AK47 said...

奇怪,为什么不能回复了呢?

KIRA said...

谢谢你的回复,我留言了几次都未能成功,不知道是不是使用了尖括号的问题,再试一下。blogspot不支持PHP,在备份的XML文件中也找不到(Blogger)(/Blogger)这样的标记。可以把修改过程再说详细点吗?

KIRA said...

果然是因为尖括号的问题...
你的blog真漂亮,第一眼看就被惊艳到了。
另外,这个分页效果似乎还有点问题,当直接跳到最后一页时仍然会显示后续数字:一共26页,直接点Last到第26页,后面还会显示27、28……出现Page 31/26 这样的错误。

Gregory said...

多谢提醒!确实是有问题,现在已经修复了~

lll9p said...

有时间我也实现一个

Coach Factory said...

coach factory, oakley sunglasses, polo ralph lauren outlet, kate spade outlet, michael kors, ray ban sunglasses, michael kors outlet, louboutin, ray ban, longchamp, louis vuitton handbags, air jordan, louboutin, prada handbags, gucci outlet, oakley sunglasses, prada outlet, coach outlet store, nike shoes, louis vuitton, polo ralph lauren, air max, michael kors outlet, louboutin, michael kors outlet, toms shoes, tory burch outlet, burberry outlet online, tiffany and co, air max, jordan shoes, nike air max, coach outlet, true religion jeans, oakley sunglasses, ray ban sunglasses, burberry outlet online, nike free, michael kors, true religion outlet, louis vuitton outlet online, true religion, chanel handbags, polo ralph lauren outlet, coach purses, nike air max, nike free, ralph lauren, longchamp outlet

Coach Factory said...

oakley outlet, moncler outlet, oakley vault, rayban, ray-ban, canada goose outlet, oakley vault, oakley sunglasses cheap, cheap sunglasses, cheap oakley, ugg boots, ugg, ray ban, ralph lauren, oakley vault, ray ban outlet, raybans, ray ban, cheap sunglasses, ray ban sunglasses outlet, louboutin, oakley, cheap sunglasses, canada goose, canada goose, canada goose, cheap oakley sunglasses, cheap oakley sunglasses, ray bans, oakley sunglasses outlet, oakley sunglasses cheap, oakley sunglasses outlet, discount oakley sunglasses, ray ban, ray bans, rayban, cheap oakley sunglasses, tn pas cher, ray ban outlet, oakley outlet, oakley outlet, moncler, oakley sunglasses outlet, canada goose, gucci, moncler, moncler, canada goose outlet, oakley sunglasses cheap

Coach Factory said...

ferragamo shoes, supra shoes, abercrombie and fitch, ray ban pas cher, wedding dresses, nfl jerseys, reebok outlet, hermes, juicy couture outlet, air max, lululemon, p90x, ghd, timberland, mulberry, lancel, hogan, new balance shoes, birkin bag, mont blanc, asics, nike air max, ugg boots, soccer jerseys, hollister, rolex watches, north face outlet, beats by dre, montre pas cher, nike free, louis vuitton, ugg boots, herve leger, chi flat iron, vans, ralph lauren, oakley pas cher, jimmy choo, insanity, converse shoes, louis vuitton, karen millen, celine handbags, bottega veneta, marc jacobs, soccer shoes, mcm handbags, yoga pants, burberry, valentino shoes

mao yun said...

2
hollister pas cher
michael kors canada
oakley vault
beats by dre,dr dre,beats headphones
kate spade outlet
fred perry shirts
oakley sunglasses
oakley sunglasses
links of london jewellery
michael kors handbags
jordan shoes
gucci handbags
puma shoes
ed hardy jeans
coach outlet online
burberry handbags
beats headphones
ray ban sunglasses
kate spade handbags
rolex watches
burberry handbags
karen millen uk
abercrombie outlet
ray ban
prada outlet
coach outlet
nfl jerseys
toms outlet
hollister clothing
asics gel kayano
pandora
toms outlet
coach outlet online
ghd hair
insanity max 30
mcm backpack
coach factory outlet
ray ban sunglasses
polo lacoste pas cher
air max 95
true religion jeans
20150330maoqiuyun

mao yun said...

5
mlb jerseys
ralph lauren outlet
tods outlet
cheap oakley sunglasses
lululemon outlet online
converse all star
jordan 4 retro
ed hardy clothing
coach outlet store
salomon running shoes
air jordan 4
pandora charms
discount oakley sunglasses
toms shoes outlet online
lebron shoes
marc jacobs outlet
coach factory outlet
abercrombie and fitch
ralph lauren outlet online
kate spade handbags
burberry outlet
coach outlet
lacoste polo shirts
kate spade
michael kors outlet online
louis vuitton
coach outlet store
coach outlet store
mont blanc pens for sale
ferragamo belts
tiffany and co jewelry
hollister uk
abercrombie and fitch
nike air force 1
snapback hats wholesale
lebron james shoes
air jordan concord
foamposite gold
ralph lauren outlet
pandora jewelry
air force one shoes
20150330maoqiuyun

Guo Guo said...

air max 90
bottega veneta outlet
nike air max uk
nike huarache
custom mlb jerseys
surpa sneakers
coach outlet
seattle seahawks jerseys
the north face uk
kansas city chiefs jerseys
nike outlet store
atlanta falcons jersey
chanel handbags
green bay packers jerseys
michael kors uk
los angeles clippers jerseys
burberry outlet
dallas cowboys jersey
nike running shoes
arizona cardinals jerseys
oakley sunglasses canada
the north face outlet
oakley sunglasses
real madrid jersey
cleveland cavaliers jersey
pittsburgh steelers jersey
north face jackets
soccer shoes
mizuno running
san francisco 49ers jerseys
dansko outlet
new orleans saints jerseys
new york jets jerseys
air jordan shoes
los angeles lakers jerseys
north face outlet
mulberry uk
hermes belt
stuart weitzman boots
washington redskins jerseys
wei20150610

Xiaozhengmm 123 said...

2015-7-28 xiaozhengm
christian louboutin sale
polo ralph lauren outlet
longchamp outlet
michael kors handbags
coach factory outlet
replica watches cheap
ed hardy
pandora rings
tory burch shoes
ralph lauren outlet
soccer jerseys wholesale
michael kors handbag
prada handbags
cheap ray ban sunglasses
chanel outlet
hollister clothing store
burberry outlet online
tory burch outlet
cheap jerseys
tory burch outlet online
cheap jordans
ray ban outlet
coach outlet online
air max 90
ralph lauren uk
coach outlet
kate spade bags
coach outlet
nike air force
chaussure louboutin
nike air max
tory burch handbags
air max shoes
air jordan
nike blazer
nike blazer low
jordan homme
michael kors
abercrombie
gucci

Hua Cai said...

coach handbags, http://www.coachhandbagsoutletonline.us.com/
prada handbags, http://www.pradahandbagsoutlet.co.uk/
the north face outlet, http://www.northface-outlet.cc/
karen millen dresses, http://www.karenmillendressesoutlets.co.uk/
coach outlet online, http://www.coachoutletonline.in.net/
michael kors handbags, http://www.michaelkorshandbag.co.uk/
true religion jeans, http://www.truereligionjeansoutlet.com/
north face outlet, http://www.thenorthface.me/
pandora jewelry, http://www.pandora.eu.com/
swarovski jewelry, http://www.swarovski.in.net/
ray ban sunglasses, http://www.raybansunglassesonline.us.com/
mulberry outlet, http://www.mulberryoutlet.com.co/
toms outlet, http://www.tomsoutlet-stores.com/
soccer jerseys, http://www.soccerjerseys.us.com/
mcm outlet, http://www.mcm.in.net/
replica handbags, http://www.replicahandbag.us.com/
michael kors outlet, http://www.michaelkorsoutletusa.net/
wedding dresses, http://www.weddingdressesoutlet.co.uk/
ugg boots, http://www.uggbootscheap.eu.com/
cheap nhl jerseys, http://www.nhljerseys.us.com/
coach outlet online, http://www.coachoutletonline-store.us.com/
nike air max uk, http://www.nikeairmaxshoes.org.uk/
true religion jeans, http://www.truereligionjean.in.net/
air jordan 4, http://www.airjordan4.org/
christian louboutin online, http://www.christianlouboutinonline.us.com/
2015929caihuali

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...

air max 90
prada outlet
chanel outlet store
louis vuitton handbags
kobe shoes
rolex watches
hollister uk
fitflops outlet sale
north face outlet
nhl jerseys
moncler outlet
canada goose outelt
coach outlet store
ghd uk
mulberry outlet store
air jordan shoes for sale
toms outlet
longchamp handbags
michael kors outlet
hermes outlet store
mm1205

方松腾 said...

michael kors handbags,michael kors outlet,michael kors,kors outlet,michael kors outlet online,michael kors outlet online sale,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors
mlb jerseys wholesale
cheap mlb jerseys
cheap nfl jerseys
nfl jerseys wholesale
nike shoes
cheap oakley sunglasses
snapback hats
soccer jerseys,cheap soccer jerseys,cheap soccer jerseys for sale,soccer jersey,usa soccer jersey,football jerseys
cheap uggs
cheap ugg boots
ugg boots
uggs outlet
wedding dresses
chicago blackhawks

方松腾 said...

michael kors handbags,michael kors outlet,michael kors,kors outlet,michael kors outlet online,michael kors outlet online sale,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors
mlb jerseys wholesale
cheap mlb jerseys
cheap nfl jerseys
nfl jerseys wholesale
nike shoes
cheap oakley sunglasses
snapback hats
soccer jerseys,cheap soccer jerseys,cheap soccer jerseys for sale,soccer jersey,usa soccer jersey,football jerseys
cheap uggs
cheap ugg boots
ugg boots
uggs outlet
wedding dresses
chicago blackhawks

Chenzhen 20160303chenzhen said...

michael kors outlet
michael kors canada
coach factory outlet
louis vuitton borse
lululemon outlet store
longchamp uk
prada handbags
cartier
adidas shoes
cheap oakley sunglasses
adidas pure boost black
oakley sunglasses
rolex daytona
stephen curry basketball shoes
coach factory outlet
ed hardy uk
converse outlet
coach outlet online
new balance shoes
valentino bags
true religion
fitflops sale clearance
gucci handbags outlet
coach outlet online
ferragamo outlet
cheap jordan shoes
under armour outlet store
cheap basketball shoes
kate spade outlet
coach factory outlet
michael kors outlet online
versace sunglasses
louboutin shoes
ugg boots
canada goose outlet
cheap nfl jerseys
michael kors handbgas
cheap oakleys
michael kors outlet
dior sunglasses 2016
chenzhen20160429

chenlili said...

chenlili20160629
retro 11
timberland outlet
louis vuitton handbags
longchamp handbags
cheap jordans
nike huarache
nike roshe run
louis vuitton outlet
coach factory outlet online
christian louboutin shoes
fitflop sandals
coach factory outlet
louis vuitton purses
nike outlet
ralph lauren outlet
polo ralph lauren
burberry bags
coach factory outlet online
nfl jerseys wholesale
louis vuitton outlet online
celine bags
true religion sale
louis vuitton purses
ralph lauren polo
true religion outlet
kobe 9
tory burch boots
coach factory outlet
adidas superstar
adidas nmd
nike free run 2
louis vuitton outlet
nike outlet store
air jordan 8
adidas running shoes
michael kors outlet clearance
copy watches
tory burch outlet online
coach outlet store online clearances

chenlili said...

chenlili20160629
air force 1
louboutin shoes
oakley vault
michael kors handbags
retro 11
ray ban sunglasses outlet
michael kors outlet
polo ralph lauren
coach outlet store online
adidas originals
tory burch handbags
coach outlet
louis vuitton purses
michael kors handbags
ray ban sunglasses outlet
coach outlet store online
rolex watches
designer handbags
louis vuitton bags
nike sb dunks
louis vuitton outlet stores
rolex watches
louis vuitton outlet
giuseppe zanotti outlet
ray ban sunglasses
nike blazers uk
ray ban sunglasses
coach outlet
nike store
ray ban sunglasses outlet
coach outlet
ghd hair straighteners
jordan retro 4
louis vuitton purses
coach outlet store online clearances
asics outlet
polo ralph lauren
nike sb janoski
jordan 3 white cenment

Gege Dai said...

jianbin0701
michael kors outlet
mcm outlet
michael kors outlet online
hermes outlet
nike air max
reebok shoes
michael kors outlet
replica watches
rolex watches
fitflops sale clearance
coach outlet online
coach outlet online
ferragamo outlet
camisetas futbol baratas
nike uk store
mulberry bags
louis vuitton neverfull sale
oakley sunglasses
mulberry handbags sale
michael kors uk outlet
tory burch outlet
louis vuitton outlet online
michael kors outlet
cheap mlb jerseys
soccer jerseys wholesale
michael kors uk
coach handbags outlet
louboutin pas cher
adidas uk store
toms outlet
lacoste shirts
oakley sunglasses uk
tory burch outlet
chrome hearts outlet

dong dong23 said...

instyler curling iron
ugg boots
hollister clothing
coach outlet
canada goose outlet
michael kors outlet
rolex watches
coach factory outlet
louis vuitton outlet
ugg outlet
201610.19wengdongdong

mmjiaxin said...

longchamp handbags
michael jordan shoes
jordan retro
nfl jerseys
nfl jerseys from china
mlb jerseys wholesale
timberland outlet
longchamp bags
kobe shoes
http://www.michaeljordanshoes.us.com
gg

琐事 said...

michael kors handbags wholesale
cheap nfl jerseys wholesale
instyler max 2
nike huarache trainers
ed hardy outlet
pandora charms
michael kors handbags sale
tiffany and co outlet
lebron shoes
longchamp le pliage

chenmeinv0 said...

nike tn pas cher
hollister outlet
seahawks jerseys
ugg boots
kate spade outlet
louboutin femme
cheap uggs
cheap uggs
fitflop clearance
ugg slippers
2016.11.14xukaimin

xumeiqing said...

20161117meiqing
toms outlet
coach outlet store
polo ralph lauren outlet online
canada goose outlet
michael kors canada
adidas stan smith
ugg australia
coach outlet
gucci handbags
nike cortez

chenmeinv0 said...

oakley sunglasses
goose outlet
moncler jackets uk
rolex watches
red bottoms
christian louboutin outlet
longchamp bags
cheap ugg boots
oakley sunglasses outlet
ed hardy
hzx20170206

Hua Cai said...

louis vuitton outlet stores
tiffany and co
true religion outlet uk
coach outlet store
pandora outlet
tory burch outlet stores
true religion outlet
pandora charms sale clearance
ralph lauren shirts
michael kors factory outlet
20170207caihuali

dong dong23 said...

ray ban sunglasses outlet
oakley vault
coach outlet
christian louboutin sale
louboutin uk
ralph lauren shirts
coach factory outlet
hollister clothing
ugg boots sale
hermes scarf
2017.2.11chenlixiang

Gege Dai said...

cheap jordans
oakley sunglasses wholesale
yeezy boost 350
hermes bags
michael kors canada
jerseys wholesale
ray ban wayfarer
chrome hearts outlet
beats by dr dre
christian louboutin outlet
20170215lck

Meiqing Xu said...

michael kors bags
polo ralph lauren outlet
kate spade uk
michael kors outlet clearance
louis vuitton handbags
fendi bags
fitflops sale
yeezy boost 350
pandora charms
coach outlet online
20170308huazhen

Unknown said...

cheap oakley sunglasses
oakley sunglasses
air max uk
jordan shoes
sac louis vuitton pas cher
cheap ray ban sunglasses
louis vuitton handbags
air max 90
coach factory outlet
michael kors outlet clearance
chanyuan2017.04.01

xjd7410@gmail.com said...

20170513 junda
yeezy boost
burberry canada
cheap jordan shoes
rolex watches for sale
gucci outlet online
ralph lauren outlet
coach factory outlet
fitflops sale clearance
polo outlet
michael kors handbags outlet

shengda xu said...

san francisco giants jerseys
rayban
ultra boost
michael kors
michael kors outlet
air max 95
michael kors outlet
sac longchamp pliage
clarks shoes
coach outlet store
xushengda0609