Message from discussion
Why does PhotoEntry.getViewCount() always return null?
Received: by 10.224.27.14 with SMTP id g14mr2991134qac.1.1348081719000;
Wed, 19 Sep 2012 12:08:39 -0700 (PDT)
X-BeenThere: google-picasa-data-api@googlegroups.com
Received: by 10.224.101.68 with SMTP id b4ls3239068qao.0.gmail; Wed, 19 Sep
2012 12:08:36 -0700 (PDT)
Received: by 10.224.31.20 with SMTP id w20mr3079333qac.2.1348081715977;
Wed, 19 Sep 2012 12:08:35 -0700 (PDT)
Received: by 10.224.29.11 with SMTP id o11msqac;
Wed, 19 Sep 2012 11:10:04 -0700 (PDT)
Received: by 10.52.90.69 with SMTP id bu5mr1017919vdb.6.1348078204451;
Wed, 19 Sep 2012 11:10:04 -0700 (PDT)
Date: Wed, 19 Sep 2012 11:10:03 -0700 (PDT)
From: Bmeist <br...@tigernet.com>
To: google-picasa-data-api@googlegroups.com
Message-Id: <76817bd4-5a0d-49b0-a96d-a4d75c0e9c0d@googlegroups.com>
In-Reply-To: <ac9c2b6a-0727-43f0-af8a-7b4bbed4f620@googlegroups.com>
References: <efa956fa-8ffe-4579-9ac4-4237af884ab1@googlegroups.com>
<ac9c2b6a-0727-43f0-af8a-7b4bbed4f620@googlegroups.com>
Subject: Re: Why does PhotoEntry.getViewCount() always return null?
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_6_25279961.1348078204045"
------=_Part_6_25279961.1348078204045
Content-Type: multipart/alternative;
boundary="----=_Part_7_14093306.1348078204045"
------=_Part_7_14093306.1348078204045
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Hey Mike, thanks very much! Any solution that works is a good one in my
book :) I will give this a shot.
--Brian.
On Tuesday, September 18, 2012 7:11:54 PM UTC-4, Mike Erickson wrote:
>
> I have a solution,although you might not think it's a good solution. The
> problem is that the view count is only correctly returned for PhotoEntry
> requests that are requested directly. So although the AlbumFeed contains
> PhotoEntry objects, those objects will not work for you.
>
> But you can do this:
>
> String albumId = "5789637314433011089";
> feedURL = new URL(
> String.format("
> https://picasaweb.google.com/data/feed/api/user/default/albumid/%s?v=2&kind=photo",
> albumId));
>
> AlbumFeed albumFeed = myService.getFeed(feedURL, AlbumFeed.class);
> for (PhotoEntry photo : albumFeed.getPhotoEntries()) {
> String photoId = photo.getGphotoId();
> URL photoEntryUrl = new URL(
> String.format("
> https://picasaweb.google.com/data/entry/api/user/default/albumid/%s/photoid/%s?v=2
> ",
> albumId, photoId));
> PhotoEntry photoEntry = myService.getEntry(photoEntryUrl,
> PhotoEntry.class);
> System.out.println("View count = " + photoEntry.getViewCount());
> }
>
> The thing to notice is that the URL for the nested request is
> .../data/entry/api... instead of .../data/feed/api...
>
> I hope that helps, at least a little.
> -Mike
>
> On Tuesday, September 18, 2012 12:38:27 PM UTC-7, Bmeist wrote:
>>
>> Greetings, I cannot seem to get anything other than null to return from
>> PhotoEntry.getViewCount(). All of my photos have view counts shown on the
>> picasaweb interface. Also, hasViewCountExt() returns false for all of
>> them. If I paste the URL into a browser and view the source, I can see the
>> correct view count. Thanks very much for any advice!
>>
>> URL feedURL = new URL("
>> https://picasaweb.google.com/data/feed/api/user/118157739053519600454/albumid/5783763403683349537/photoid/5783763444234578498?v=2
>> ");
>>
>> Query query = new Query(feedURL);
>> query.setStringCustomParameter("kind", "photo");
>>
>> int numPhotos = feed.getPhotoEntries().size();
>> AlbumFeed feed = picasaService.query(query, AlbumFeed.class);
>> for (int i = 0; i < numPhotos; i++) {
>> PhotoEntry photo = (PhotoEntry) feed.getPhotoEntries().get(i);
>> System.out.println("view count = " + photo.getViewCount());
>> }
>>
>>
>>
>>
>>
------=_Part_7_14093306.1348078204045
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hey Mike, thanks very much! Any solution that works is a good one in =
my book :) I will give this a shot.<div><br></div><div>--Brian.<br><b=
r>On Tuesday, September 18, 2012 7:11:54 PM UTC-4, Mike Erickson wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;">I have a solution,although you mig=
ht not think it's a good solution. The problem is that the view count=
is only correctly returned for PhotoEntry requests that are requested dire=
ctly. So although the AlbumFeed contains PhotoEntry objects, those objects =
will not work for you. <div><br></div><div>But you can do this:</div><=
div><br></div><div><div> String albumId =3D "5789637314=
433011089";</div><div> feedURL =3D new URL(</div><div>&=
nbsp; String.format("<a href=3D"https://picasaweb.goog=
le.com/data/feed/api/user/default/albumid/%s?v=3D2&kind=3Dphoto" target=
=3D"_blank">https://<wbr>picasaweb.google.com/data/<wbr>feed/api/user/defau=
lt/albumid/<wbr>%s?v=3D2&kind=3Dphoto</a>", albumId));</div><div><br></=
div><div> AlbumFeed albumFeed =3D myService.getFeed(fee=
dURL, AlbumFeed.class);</div><div> for (PhotoEntry phot=
o : albumFeed.getPhotoEntries()) {</div><div> St=
ring photoId =3D photo.getGphotoId();<br></div><div> &n=
bsp; URL photoEntryUrl =3D new URL(</div><div> &=
nbsp; String.format("<a href=3D"https://picasaweb.google.com/data/en=
try/api/user/default/albumid/%s/photoid/%s?v=3D2" target=3D"_blank">https:/=
/<wbr>picasaweb.google.com/data/<wbr>entry/api/user/default/<wbr>albumid/%s=
/photoid/%s?v=3D2</a>",</div><div> =
albumId, photoId));</div><div> PhotoEntry photo=
Entry =3D myService.getEntry(<wbr>photoEntryUrl, PhotoEntry.class);<br></di=
v><div> System.out.println("View count =3D " + p=
hotoEntry.getViewCount());<br></div><div> }</div><div><=
br></div><div>The thing to notice is that the URL for the nested request is=
.../data/entry/api... instead of .../data/feed/api...</div><div><br></div>=
<div>I hope that helps, at least a little.</div><div>-Mike</div><br>On Tues=
day, September 18, 2012 12:38:27 PM UTC-7, Bmeist wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div><div>Greetings, I cannot seem to get anything o=
ther than null to return from PhotoEntry.getViewCount(). All of my ph=
otos have view counts shown on the picasaweb interface. Also, hasView=
CountExt() returns false for all of them. If I paste the URL into a b=
rowser and view the source, I can see the correct view count. Thanks =
very much for any advice! </div><div><br></div><div> &nbs=
p; URL feedURL =3D new URL("<a href=3D"https://picasaweb.google.com/data/fe=
ed/api/user/118157739053519600454/albumid/5783763403683349537/photoid/57837=
63444234578498?v=3D2" target=3D"_blank">https://picasaweb.google.<wbr>com/d=
ata/feed/api/user/<wbr>118157739053519600454/albumid/<wbr>57837634036833495=
37/photoid/<wbr>5783763444234578498?v=3D2</a>");</div><div><br></div><div>&=
nbsp; Query query =3D new Query(feedURL);</div><div> &n=
bsp; query.<wbr>setStringCustomParameter("<wbr>kind", "photo");</div=
><div><br></div><div> int numPhotos =3D feed.getPhotoEn=
tries().size();<br></div><div> AlbumFeed feed =3D picas=
aService.query(query, AlbumFeed.class);</div><div> for =
(int i =3D 0; i < numPhotos; i++) {<br></div><div> &=
nbsp; PhotoEntry photo =3D (PhotoEntry) feed.getPhotoEntries().g=
et(i);</div></div><div> System.out.println=
("view count =3D " + photo.getViewCount());<br></div><div> &nb=
sp; }</div><div><br></div><div><br></div><div><br></div><div><br></div></bl=
ockquote></div></blockquote></div>
------=_Part_7_14093306.1348078204045--
------=_Part_6_25279961.1348078204045--