Support » Plugin: Shashin » Hack to get Shashin to display the old Picasa Albums [temporarily solved]

  • Resolved Gwyneth Llewelyn

    (@gwynethllewelyn)


    As of May 2016, as many of you know, Google stopped supporting Picasa; and since August 2016, most of the functionality of Picasa was taken down, and pages started to get redirected to Google Photos instead. Google claims that ‘old APIs’ are still supported, and that’s true to a degree, but things simply got much, much harder to fix.

    In particular, Shashin requires a ‘page’ from which it can extract an RSS feed. The author, Mike Toppa, has not given us an alternative to load the images. While Google somehow redirected people to a page where there was an RSS feed, Shashin would cleverly get it, and would continue to work. Unfortunately, at this moment, there seems to be no way to generate a page which continues to have the embedded RSS feeds on it. I actually checked with one Google dev (a personal friend of mine) and this was deliberate: they were worried about some users who clicked on the ‘wrong’ links and basically allowed anyone to get the RSS feed — which was not what they intended at all! So, to refrain stupid users to make mistakes, they simply removed that functionality from Google Photos.

    Now, because so many plugins and apps and whatnot rely upon those RSS feeds still working, Google did not change the actual calls. In fact, I even managed to find two different RSS feeds from the same user/album combination; they present data in a slightly different way, and are basically two different ‘generations’ of code development. Both still work fine.

    The problem, of course, is to figure out how to construct the RSS feed, and, secondly, get Shashin to work with a RSS feed directly, instead of relying on a page to extract the feed.

    1. Figuring out the RSS feed

    Picasa and Google Photos both use the notion of user IDs and album IDs, and, optionally, an authentication key for private albums. Unfortunately (or deliberately?) Google changed all the IDs when moving from Picasa to Google Photos.

    You can try to assemble a valid RSS feed using several solutions. One is described here: http://41kzone.blogspot.pt/2013/05/getting-media-rss-feed-from-google.html — although the article is three years old, the constructed RSS URLs do still work. Another way is to follow the instructions on this WordPress support thread — https://wordpress.org/support/topic/how-to-use-plugin-after-migration-to-google-photos/ While the original instructions don’t seem to be working any more, the suggestion made in the comments by @cra1gster will still work.

    However, there might be a catch with albums with authkeys; depending on when they were uploaded, the way Google handles them (from within the Google pages) has changed — new authkeys, what used to be ‘visible with link’ now requires previous authentication and is only shared with ‘friends’ (I assume this means someone in your Google Circle or something similar). Old things still work, though, and they work very well.

    Enter Casper Baghuis wonderful world of the RSSerator. Explained here on his blog post, the RSSerator is an application which allows you to log in to Google with your account (therefore using the ‘new’ method of authentication) but view all your ‘old’ Picasa albums, and, for each of them, you get not only the essential data (user ID, album ID, authkey) and a link to a well-formed RSS URL, but, as a nice bonus (and a vital one!), you can also set the visibility directly from this page — instantly, at a click of the mouse! It’s really amazing, and I can only wish that Casper Baghuis is able to maintain that site up for as long as possible!

    2. Making Shashin recognise Picasa RSS feeds

    Unfortunately, as said, to get Shashin to recognise RSS feeds from Picasa requires a small hack (which is unavoidable). Open /wp-content/plugins/shashin/admin/ShashinSynchronizerPicasa.php.

    Around line 71 you will have a method called public function retrievePicasaRssUrl(). A few lines below it there is the following code:

    if (!$rssUrl) {
                throw New Exception(__('Unable to determine RSS feed for URL', 'shashin') . ': ' . htmlentities($this->request['userUrl']));
            }
    

    Replace it by the following code:

    if (!$rssUrl) {
    	        /* Gwyneth Llewelyn's hack starts here */
    	        // check first if by any chance this is already a RSS feed we're getting
    	        
    	        $response = $this->httpRequester->request(
                	$this->request['userUrl'],
    				array('timeout' => 30, 'sslverify' => false)
    			);
    	        $rssXML = new DOMDocument();
    	        @$rssXML->loadXML($response['body']);
    	        $xpath = new DOMXpath($rssXML);
    	        
    	        if (count($xpath->query("/channel/item")) > 0) // this means it's a valid RSS feed, since there are more than 0 items in it
    	        	return $this->request['userUrl']; // I hope this is the right thing to return...
    	        
    	        /* Gwyneth Llewelyn's hack ends here */
    	        
                throw New Exception(__('Unable to determine RSS feed for URL', 'shashin') . ': ' . htmlentities($this->request['userUrl']));
            }
    

    and save the file.

    Basically, what happens in this function is the following: Shashin will load the whole page and search for a link to a RSS URL; if it fails to find one, it throws an exception. But now we are going to give Shashin not the link to a page’s album, but the correctly generated RSS feed URL, courtesy of Casper’s RSSerator. RSS feeds are in XML, so, although this operation is hardly very efficient, all I do is start parsing the whole file again, this time using XML, and search to see if there are any entries in the RSS feed — if not, either the feed is wrongly generated (it might happen in the future, if Google changes the APIs again) or has no pictures whatsoever in it (which can happen either with an empty album, or one that is private, e.g. has no permissions to be viewed by anyone else).

    If no entries are found in the RSS feed, then, yes, we should throw the exception. If there is at least one entry, then we return to the rest of Shashin the RSS URL, considering it to be ‘correct’ (and it will be).

    It works flawless for me, and I’m sure that this can be optimized (it seems a waste to load the whole page again… especially because we know that Google will very likely never put any RSS feeds into Google Photos (but who knows, they might change their minds once more…) — so possibly this could be written differently to catch the valid RSS feed much sooner…

    Caveat utilitor: If you manually change a file of a plugin, then security plugins such as Wordfence Security will start to complain that what you’ve got on disk is not the same as what is on WordPress.org’s repository. You will therefore have to instruct your security plugin to either accept or ignore this manual change.

    I’ve provisionally marked this as ‘solved’, but I’m quite aware that either Google might change their APIs again and this trick will not work any longer; or, well, if you are reading this in, say, 2020 or later, it’s possible that Casper will not have his wonderful around, and that means it will be much harder to figure out the RSS feed for your album(s)… assuming, of course, that Google will still maintain those RSS feeds working (the truth is that they have announced the ‘death’ of FeedBurner years ago, and it’s still running, happily spewing out RSS feeds…)

  • The topic ‘Hack to get Shashin to display the old Picasa Albums [temporarily solved]’ is closed to new replies.