我正在尝试从picasa api获取回复以获取相册/照片。当我这样做时,会发生奇怪的事情。我的代码没有完全响应,并得到谷歌插件“postman”的完整回复。 这是我的代码:
def self.getUserAlbums
url = "https://picasaweb.google.com/data/feed/api/user/" + @user.uid
puts @user.uid
puts url
doc = Nokogiri::XML(open(url))
puts doc
end
这是我得到的回应:
https://picasaweb.google.com/data/feed/api/user/107097732897061020403
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gphoto="http://schemas.google.com/photos/2007" xmlns:media="http://search.yahoo.com/mrss/">
<id>https://picasaweb.google.com/data/feed/api/user/107097732897061020403</id>
<updated>2014-09-04T12:22:34.062Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#user"/>
<title type="text">107097732897061020403</title>
<subtitle type="text"/>
<icon>https://lh3.googleusercontent.com/-ciT1cTht4tU/AAAAAAAAAAI/AAAAAAAAAAA/2KCtta9zU8Y/s64-c/107097732897061020403.jpg</icon>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://picasaweb.google.com/data/feed/api/user/107097732897061020403"/>
<link rel="alternate" type="text/html" href="https://picasaweb.google.com/107097732897061020403"/>
<link rel="http://schemas.google.com/photos/2007#slideshow" type="application/x-shockwave-flash" href="https://photos.gstatic.com/media/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=https://picasaweb.google.com/data/feed/api/user/107097732897061020403?alt%3Drss"/>
<link rel="self" type="application/atom+xml" href="https://picasaweb.google.com/data/feed/api/user/107097732897061020403?start-index=1&max-results=1000"/>
<author>
<name>Strange man</name>
<uri>https://picasaweb.google.com/107097732897061020403</uri>
</author>
<generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator>
<openSearch:totalResults>1</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>1000</openSearch:itemsPerPage>
<gphoto:user>107097732897061020403</gphoto:user>
<gphoto:nickname>Strange man</gphoto:nickname>
<gphoto:thumbnail>https://lh3.googleusercontent.com/-ciT1cTht4tU/AAAAAAAAAAI/AAAAAAAAAAA/2KCtta9zU8Y/s64-c/107097732897061020403.jpg</gphoto:thumbnail>
<entry>
<id>https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/5995150641832070833</id>
<published>2014-03-26T17:26:22.000Z</published>
<updated>2014-03-26T17:26:22.019Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/>
<title type="text">Profile Photos</title>
<summary type="text">Album for profile photos</summary>
<rights type="text">public</rights>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://picasaweb.google.com/data/feed/api/user/107097732897061020403/albumid/5995150641832070833"/>
<link rel="alternate" type="text/html" href="https://picasaweb.google.com/107097732897061020403/ProfilePhotos"/>
<link rel="self" type="application/atom+xml" href="https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/5995150641832070833"/>
<author>
<name>Strange man</name>
<uri>https://picasaweb.google.com/107097732897061020403</uri>
</author>
<gphoto:id>5995150641832070833</gphoto:id>
<gphoto:name>ProfilePhotos</gphoto:name>
<gphoto:location/>
<gphoto:access>public</gphoto:access>
<gphoto:timestamp>1395854782000</gphoto:timestamp>
<gphoto:numphotos>0</gphoto:numphotos>
<gphoto:user>107097732897061020403</gphoto:user>
<gphoto:nickname>Strange man</gphoto:nickname>
<gphoto:albumType>ProfilePhotos</gphoto:albumType>
<media:group>
<media:content url="https://lh4.googleusercontent.com/-3SHSUfpLzb8/UzMNvr1bDrE/AAAAAAAAAAc/eEGmx-4YiEg/ProfilePhotos.jpg" type="image/jpeg" medium="image"/>
<media:credit>Strange man</media:credit>
<media:description type="plain"/>
<media:keywords/>
<media:thumbnail url="https://lh4.googleusercontent.com/-3SHSUfpLzb8/UzMNvr1bDrE/AAAAAAAAAAc/eEGmx-4YiEg/s160-c/ProfilePhotos.jpg" height="160" width="160"/>
<media:title type="plain">Profile Photos</media:title>
</media:group>
</entry>
</feed>
但是当我使用google addon邮递员时:
<?xml version='1.0' encoding='UTF-8'?>
<feed
xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:gphoto='http://schemas.google.com/photos/2007'
xmlns:media='http://search.yahoo.com/mrss/'>
<id>https://picasaweb.google.com/data/feed/api/user/107097732897061020403</id>
<updated>2014-09-04T12:22:34.062Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#user'/>
<title type='text'>107097732897061020403</title>
<subtitle type='text'/>
<icon>https://lh3.googleusercontent.com/-ciT1cTht4tU/AAAAAAAAAAI/AAAAAAAAAAA/2KCtta9zU8Y/s64-c/107097732897061020403.jpg</icon>
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/107097732897061020403'/>
<link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/107097732897061020403?tok=QUI1UGxRWmktbk5VOU1lSm01VjB2a1hoNGR1UzhORFhSQToxNDA5ODM0MjE0MzA3'/>
<link rel='alternate' type='text/html' href='https://picasaweb.google.com/107097732897061020403'/>
<link rel='http://schemas.google.com/photos/2007#slideshow' type='application/x-shockwave-flash' href='https://photos.gstatic.com/media/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=https://picasaweb.google.com/data/feed/api/user/107097732897061020403?alt%3Drss'/>
<link rel='self' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/107097732897061020403?start-index=1&max-results=1000'/>
<author>
<name>Strange man</name>
<uri>https://picasaweb.google.com/107097732897061020403</uri>
</author>
<generator version='1.00' uri='http://picasaweb.google.com/'>Picasaweb</generator>
<openSearch:totalResults>3</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>1000</openSearch:itemsPerPage>
<gphoto:user>107097732897061020403</gphoto:user>
<gphoto:nickname>Strange man</gphoto:nickname>
<gphoto:thumbnail>https://lh3.googleusercontent.com/-ciT1cTht4tU/AAAAAAAAAAI/AAAAAAAAAAA/2KCtta9zU8Y/s64-c/107097732897061020403.jpg</gphoto:thumbnail>
<gphoto:quotalimit>16106127360</gphoto:quotalimit>
<gphoto:quotacurrent>0</gphoto:quotacurrent>
<gphoto:maxPhotosPerAlbum>2000</gphoto:maxPhotosPerAlbum>
<entry>
<id>https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6055182888376766577</id>
<published>2014-09-04T12:02:09.000Z</published>
<updated>2014-09-04T12:22:34.062Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/>
<title type='text'>September 4, 2014</title>
<summary type='text'/>
<rights type='text'>protected</rights>
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/107097732897061020403/albumid/6055182888376766577'/>
<link rel='alternate' type='text/html' href='https://picasaweb.google.com/107097732897061020403/September42014'/>
<link rel='self' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6055182888376766577'/>
<link rel='edit' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6055182888376766577/9?tok=QUI1UGxRWW9NRjVubkVZQjdIZEotOVY2VFlhM051YllHZzoxNDA5ODM0MjE0MzA3'/>
<link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6055182888376766577/acl'/>
<author>
<name>Strange man</name>
<uri>https://picasaweb.google.com/107097732897061020403</uri>
</author>
<gphoto:id>6055182888376766577</gphoto:id>
<gphoto:name>September42014</gphoto:name>
<gphoto:location/>
<gphoto:access>protected</gphoto:access>
<gphoto:timestamp>1409832129000</gphoto:timestamp>
<gphoto:numphotos>6</gphoto:numphotos>
<gphoto:numphotosremaining>1994</gphoto:numphotosremaining>
<gphoto:bytesUsed>832905</gphoto:bytesUsed>
<gphoto:user>107097732897061020403</gphoto:user>
<gphoto:nickname>Strange man</gphoto:nickname>
<media:group>
<media:content url='https://lh5.googleusercontent.com/-pX41vnK92K4/VAhUwVe4kHE/AAAAAAAAACA/WSmDsRTuWqo/September42014.jpg' type='image/jpeg' medium='image'/>
<media:credit>Strange man</media:credit>
<media:description type='plain'/>
<media:keywords/>
<media:thumbnail url='https://lh5.googleusercontent.com/-pX41vnK92K4/VAhUwVe4kHE/AAAAAAAAACA/WSmDsRTuWqo/s160-c/September42014.jpg' height='160' width='160'/>
<media:title type='plain'>September 4, 2014</media:title>
</media:group>
</entry>
<entry>
<id>https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6054471120618425345</id>
<published>2014-09-02T14:00:07.000Z</published>
<updated>2014-09-02T14:29:53.542Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/>
<title type='text'>2014-09-02</title>
<summary type='text'/>
<rights type='text'>protected</rights>
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/107097732897061020403/albumid/6054471120618425345'/>
<link rel='alternate' type='text/html' href='https://picasaweb.google.com/107097732897061020403/20140902'/>
<link rel='self' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6054471120618425345'/>
<link rel='edit' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6054471120618425345/7?tok=QUI1UGxRWWZncVExZ3p4aGhuOGN5TDdZaGVmT00zT0puZzoxNDA5ODM0MjE0MzA3'/>
<link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/6054471120618425345/acl'/>
<author>
<name>Strange man</name>
<uri>https://picasaweb.google.com/107097732897061020403</uri>
</author>
<gphoto:id>6054471120618425345</gphoto:id>
<gphoto:name>20140902</gphoto:name>
<gphoto:location/>
<gphoto:access>protected</gphoto:access>
<gphoto:timestamp>1409666407000</gphoto:timestamp>
<gphoto:numphotos>3</gphoto:numphotos>
<gphoto:numphotosremaining>1997</gphoto:numphotosremaining>
<gphoto:bytesUsed>421306</gphoto:bytesUsed>
<gphoto:user>107097732897061020403</gphoto:user>
<gphoto:nickname>Strange man</gphoto:nickname>
<media:group>
<media:content url='https://lh6.googleusercontent.com/-zxKJrQaBe3E/VAXNZ_9SjAE/AAAAAAAAABE/DztgeKHgQVM/20140902.jpg' type='image/jpeg' medium='image'/>
<media:credit>Strange man</media:credit>
<media:description type='plain'/>
<media:keywords/>
<media:thumbnail url='https://lh6.googleusercontent.com/-zxKJrQaBe3E/VAXNZ_9SjAE/AAAAAAAAABE/DztgeKHgQVM/s160-c/20140902.jpg' height='160' width='160'/>
<media:title type='plain'>2014-09-02</media:title>
</media:group>
</entry>
<entry>
<id>https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/5995150641832070833</id>
<published>2014-03-26T17:26:22.000Z</published>
<updated>2014-03-26T17:26:22.019Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/>
<title type='text'>Profile Photos</title>
<summary type='text'>Album for profile photos</summary>
<rights type='text'>public</rights>
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/107097732897061020403/albumid/5995150641832070833'/>
<link rel='alternate' type='text/html' href='https://picasaweb.google.com/107097732897061020403/ProfilePhotos'/>
<link rel='self' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/5995150641832070833'/>
<link rel='edit' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/5995150641832070833/1?tok=QUI1UGxRWklzV0VmX1JTQTlUalQ2dGdCY1NvQXdOdHB5QToxNDA5ODM0MjE0MzA3'/>
<link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/107097732897061020403/albumid/5995150641832070833/acl'/>
<author>
<name>Strange man</name>
<uri>https://picasaweb.google.com/107097732897061020403</uri>
</author>
<gphoto:id>5995150641832070833</gphoto:id>
<gphoto:name>ProfilePhotos</gphoto:name>
<gphoto:location/>
<gphoto:access>public</gphoto:access>
<gphoto:timestamp>1395854782000</gphoto:timestamp>
<gphoto:numphotos>0</gphoto:numphotos>
<gphoto:numphotosremaining>2000</gphoto:numphotosremaining>
<gphoto:bytesUsed>0</gphoto:bytesUsed>
<gphoto:user>107097732897061020403</gphoto:user>
<gphoto:nickname>Strange man</gphoto:nickname>
<gphoto:albumType>ProfilePhotos</gphoto:albumType>
<media:group>
<media:content url='https://lh4.googleusercontent.com/-3SHSUfpLzb8/UzMNvr1bDrE/AAAAAAAAAAc/eEGmx-4YiEg/ProfilePhotos.jpg' type='image/jpeg' medium='image'/>
<media:credit>Strange man</media:credit>
<media:description type='plain'/>
<media:keywords/>
<media:thumbnail url='https://lh4.googleusercontent.com/-3SHSUfpLzb8/UzMNvr1bDrE/AAAAAAAAAAc/eEGmx-4YiEg/s160-c/ProfilePhotos.jpg' height='160' width='160'/>
<media:title type='plain'>Profile Photos</media:title>
</media:group>
</entry>
</feed>
所以,如果你懒得像我一样阅读整个xml,这里有区别,邮递员请求后返回标签中的3张专辑,但我的代码只返回1张专辑(最后一张)。如果你想检查自己,请求是第一个第一反应的行。请回答。