This is true for a number of different fields throughout the Picasa API. I
do this loop when going from user to album to photo to etc... I never rely
on the atom feed data only the atom entry data. Seems a bit of a poor
design, but it has saved me hours of wracking around like this.

 

Paul.

 

From: google-picasa-data-api@googlegroups.com
[mailto:google-picasa-data-api@googlegroups.com] On Behalf Of Mike Erickson
Sent: Tuesday, September 18, 2012 7:12 PM
To: google-picasa-data-api@googlegroups.com
Subject: [PWA API] Re: Why does PhotoEntry.getViewCount() always return
null?

 

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/album
id/%s?v=2
<https://picasaweb.google.com/data/feed/api/user/default/albumid/%25s?v=2&ki
nd=photo> &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/albu
mid/%s/photoid/%s?v=2
<https://picasaweb.google.com/data/entry/api/user/default/albumid/%25s/photo
id/%25s?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/a
lbumid/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());

      }

 

 

 

 

-- 
You received this message because you are subscribed to the Google Groups
"Google Picasa Web Albums API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-picasa-data-api/-/tt7qtN-BIGUJ.
To post to this group, send email to
google-picasa-data-api@googlegroups.com.
To unsubscribe from this group, send email to
google-picasa-data-api+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-picasa-data-api?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To post to this group, send email to google-picasa-data-api@googlegroups.com.
To unsubscribe from this group, send email to 
google-picasa-data-api+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-picasa-data-api?hl=en.

Reply via email to