how can I use picasa API ?

Oct 29, 2008 at 11:56 PM
how can I use picasa API ? there is nothing about picasa API in documentation...
Coordinator
Oct 30, 2008 at 7:02 PM
Hi Kralcak

Out of the box slide.Show 2 does not support the picasa API. however our data provider api is extendable and with a bit of C# knowledge you should be able to follow the pattern of the Flickr Data Provider within the source code and implement your own.

Cheers,
Liam
Nov 18, 2008 at 2:06 PM
I am creating a PicasaDataProvider today. I will post the results this afternoon or first thing tomorrow morning. :) Cheers.
Nov 19, 2008 at 5:20 AM

Hello all,

I have successfully created a PicasaDataProvider for Slide.Show2! That was by far one of the most frustrating projects I have taken on. OK, to begin, Google's Picasa API in coordination with Silverlight 2 does not support querying Picasa Google directly. This is because Picasa Google's server contains a cross domain xml file that is content-type-specific. For now, Silverlight does not support it. So to work around the problem i created a custom web service to partner with the html page hosting the Silverlight Application. The webservice can be placed anywhere, but the object parameter in the html page must specify where the webservice lives. Also the webservice is using the new Google API, so that must be referenced in the web application. You cannot reference the Google .net Library in the silverlight application because it is not a valid Silverlight reference. The following link will take you to the example application on my personal website. That particular application will take about 30 seconds to load because it is linked to MY picasa web albums account. (I have 56 albums and about 2500 images.) I think that with a reasonably sized web albums account you could decrease the load time tremendously. Link: http://wesleyriley.com/SlideShow2/Default.html. (Click the Picasa Link on the page.) The solution can be downloaded by clicking the following link. Remember, if you choose to use the project make sure you adjust the object parameter in the html page that houses the Silverlight object to reflect Visual Studio's auto port number. Link: http://wesleyriley.com/SlideShow2/Project/SlideShowWithPDP.zip.

Cheers!

If you have any questions shoot me an email at: rileywesley@gmail.com

Wes

Nov 19, 2008 at 2:57 PM
Edited Nov 19, 2008 at 3:13 PM

Hi Wes,
Really great work... but what a co-incidence even i was working on similar lines to get Picasa Data in to Vertigo Slid Show 2.0. Almost we had a same approch only difference was in our algorithm.
I used LINQ to make my code short. My web service returns XML string similar to the format required by XmlDataProvider and then I parse the xml into Data.Albums. Below are the code codes snippets :

Web Service : PicasaData.asmx.cs (Needs reference to  Google.GData.Client, Google.GData.Photos & Google.GData.Extensions)
[WebMethod]
public string GetPicasaDataXml(string picasaId)
{
  try
  {
    PicasaService picasaService = new PicasaService("MyPicasaService");
    XElement picasaXml = new XElement("data",
                         new XAttribute("startalbumindex", "0"),
                         new XAttribute("transition", GetRandomTransition()),
                         from PicasaEntry entry in picasaService.Query(new AlbumQuery(PicasaQuery.CreatePicasaUri(picasaId))).Entries
                              select new XElement("album",
                                     new XAttribute("title", entry.Title.Text),
                                     new XAttribute("description", entry.Summary.Text),
                                     new XAttribute("source", entry.Media.Thumbnails[0].Url),
                                     new XAttribute("transition", GetRandomTransition()),
                                     from PicasaEntry photoEntry in picasaService.Query(new PhotoQuery(entry.FeedUri)).Entries
                                          select new XElement("slide",
                                                 new XAttribute("title", photoEntry.Title.Text),
                                                 new XAttribute("description", photoEntry.Summary.Text),
                                                 new XAttribute("source", photoEntry.Media.Content.Attributes["url"].ToString()),
                                                 new XAttribute("thumbnail", photoEntry.Media.Thumbnails[0].Url),
                                                 new XAttribute("transition", GetRandomTransition()))));
    
    picasaXml.Elements().Where(f => !f.HasElements).Remove();

    return picasaXml.ToString();
    }
    catch (Exception ex)
    {
         throw new Exception("Error accessing Picasa Data : " + ex.Message, ex);
    }
 }

 public static Random R = new Random();
 private string GetRandomTransition()
        {
            string[] transactions = new string[] {"CircleInTransition", "CircleOutTransition",  "CrossFadeTransition", 
                                                    "SlideDownTransition", "SlideLeftTransition", "SlideRightTransition", 
                                                    "SlideUpTransition", "TranslateDownTransition", "TranslateLeftTransition",
                                                    "TranslateRightTransition","TranslateUpTransition"  };

            return transactions[R.Next(0, transactions.Length)];
        }

 

 

 

 Picasa Data Provider within silverlight project PicasaDataProvider.cs
PicasaDataWS is the Web Service Reference name 

public class PicasaDataProvider : IDataProvider
{

  #region Constants
   private string MainFeedUrl = @http://picasaweb.google.com/data/feed/api/user/{0};
   private string AlbumFeedUrl = @http://picasaweb.google.com/data/feed/api/user/{0}/album/{1};
   #endregion

   #region Public Properties
   public string PicasaID { get; set; }
   #endregion

   #region IDataProvider Members
   public event EventHandler DataFinishedLoading;
   #endregion

   #region Constructor
   public PicasaDataProvider(Dictionary<string, />> initParams)
   {
     PicasaID = initParams.ContainsKey("DataProvider") ?
                   initParams["DataProvider"].ContainsKey("PicasaId") ?
                                     initParams["DataProvider"]["PicasaId"] :
                                            string.Empty :
                                            string.Empty;

     if (string.IsNullOrEmpty(PicasaID))
     {
           throw new Exception("Error while retriving Picasa Data : Invalid Picasa ID ");
      }

   BasicHttpBinding bind = new BasicHttpBinding();
   EndpointAddress endpoint = new EndpointAddress(@"http://www.something.com/webser/picasadata.asmx"); //User WebService URL here

   PicasaDataWS.PicasaDataSoapClient service = new Vertigo.SlideShow.PicasaDataWS.PicasaDataSoapClient(bind, endpoint);
   service.GetPicasaDataXmlAsync(PicasaID);
   service.GetPicasaDataXmlCompleted += new EventHandler<vertigo.slideshow.picasadataws.getpicasadataxmlcompletedeventargs >      
                                      (service_GetPicasaDataXmlCompleted);
  }
  #endregion

        void service_GetPicasaDataXmlCompleted(object sender, Vertigo.SlideShow.PicasaDataWS.GetPicasaDataXmlCompletedEventArgs e)
        {
           
            XmlReader reader = XmlReader.Create(new StringReader(e.Result));
            XElement xml = XElement.Load(reader);

            Data.StartAlbumIndex = int.Parse(xml.Attribute("startalbumindex").Value);
            Data.Albums  = (from el in xml.Elements()
                             select new Album
                             {
                                 Title = el.Attribute("title").Value,
                                 Description = el.Attribute("description").Value,
                                 Thumbnail = new Uri(el.Attribute("source").Value),
                                 Slides = (from singleSlide in el.Elements()
                                           select new Slide
                                           {
                                               Title = singleSlide.Attribute("title").Value,
                                               Description = singleSlide.Attribute("description").Value,
                                               Thumbnail = new Uri(singleSlide.Attribute("thumbnail").Value),
                                               Source = new Uri(singleSlide.Attribute("source").Value),
                                               Link = null,
                                               Preview = null,
                                               Transition = singleSlide.Attribute("transition").Value
                                           }).ToArray<slide />()
                             }).ToArray<album />();

           
            DataFinishedLoading(this, EventArgs.Empty);
        }    
       
    }

 Thanks & Regards,
Pinal Bhatt
pinal-bhatt@live.com

 

 

 

Jan 29, 2009 at 11:00 PM
Ah ha.... I finally have Vertigo Silde.Show2 with Picasa Data Provider which does not needs third party web service call. I have tried to achieve direct call to Picasa feeds from the SL app using JSON. You can have demo here and for download and more details go here.

Thanks & Regards,
Pinal Bhatt
www.P-Bhatt.com
Mar 11, 2009 at 2:06 AM
I didn't create a picasa data provider but if anybody want to create a xml data file from picasa web albums can take a look at :
http://mefeozer.wordpress.com/2009/03/10/create-data-file-for-slideshow2-from-picasa-web-albums/