Wednesday, July 20, 2011

Get picky with the Google Picker API


By Chris Thrasher, Software Engineer, Google Picker API

Users have content across many Google properties: YouTube, Picasa Web Albums, Google Docs, and more. Now we have a common interface for your users to select Google content. The Google Picker API provides a familiar-looking dialog box that’s easy for you to integrate into your apps. Your users can quickly browse their own content without ever leaving your page or app.

Perhaps you’re developing a blogging platform and you want your users to be able to embed their Picasa Web Albums photos. You can even let your users pick from public content, as found from image and video search.

Once the Picker is invoked by your user, a modal dialog appears on the page. If the user is already signed in to their Google account, they’ll see their content in just a second or two. If not, the user will be asked to sign in.


Integrating with the Google Picker API is straightforward. First, you specify which Google services should show up as options in the Picker navigation. For example, if you’re a photo site, you may choose to show Picasa and Google Image Search, but hide Google Docs and other services. Then, you simply specify a callback function that will be called as soon as the user’s data is returned to your application.
var picker = new google.picker.PickerBuilder().
    addView(google.picker.ViewId.IMAGE_SEARCH).
    setCallback(pickerCallback).
    build();
picker.setVisible(true);
You can find more integration details and examples in the documentation. We hope you enjoy this new API!

Chris Thrasher is a Software Engineer at Google Kirkland and is part of the Google+ team. When he's not writing code, Chris is usually watching old movies. Or quoting from them.

Posted by Scott Knaster, Editor

11 comments:

  1. Oh cool! Will Google be using this internally to allow us to add attachments from Docs, Picasa, etc. in Gmail?

    ReplyDelete
  2. Now, that is uber awesome.

    ReplyDelete
  3. Great new functionality. Looks like the documented google.picker.​ViewId.UPLOAD type does not work.

    Tested in Chrome Stable 12.x.

    Error: Uncaught TypeError: Cannot call method 'ma' of undefined

    --
    var picker = new google.picker.PickerBuilder().
    addView(google.picker.ViewId.UPLOAD).
    setCallback(pickerCallback).
    build();
    --

    Also a very very strange thing, at least from my understanding is that you do NOT get the path to the file. But only to the 'site' above it. Like you do not get the filename for a picture in Picasa, but the site that will display the picture. Also the same for Google Image Search. That will make it unusable?

    Looks like it is not yet that powerfull. I see you can do something with the thumbs (for Google Image Search part) in the data object, but then you need to guess which one should it be, the first is the image link from the Google Cache, the second is the link to the direct picture.

    So after testing it, I dont know what the use of it should be? Regards!

    ReplyDelete
  4. Only uploading to Picasa is currently available. The ViewId is PHOTO_UPLOAD.

    For photos and image search, the doc field in the return value is, as you state, the URL of the page containing the image. The *last* element in the thumbnails array should be the URL to the full-size image itself. The naming could be better, I agree.

    ReplyDelete
  5. Haha. Ok.

    Thanks for the information :)

    Would be nice if the documentation could be updated a little on this (pointing to site), how to use the results.

    And probably a clear 'variable' / property that indicates that direct url instead of probably 'dynamic' *last* value and doing things like .length-1 things :)

    ReplyDelete
  6. I'll try and update the results guide: http://code.google.com/apis/picker/docs/results.html based on your feedback.

    As for aliasing the full-size image URL in another field is something my team will discuss.

    ReplyDelete
  7. yeah a new API, when will you deprecate it? ok, sorry, that is a little harsh, i'm just frustrated that Google promised to de-deprecate the translate API (see http://googlecode.blogspot.com/2011/05/spring-cleaning-for-some-of-our-apis.html) but well, if i visit http://code.google.com/apis/language/translate/overview.html the death API death clock is still ticking.... yeah, i know we are just developers and these are your APIs, but any news from that front? asks and best regards franz enzenhofer, austria, vienna

    ReplyDelete
  8. with this method we can simply take the link in question!
    awesome \m/

    ReplyDelete
  9. franz is right, we want to get news about your tanslate API. It is a good product and it s y pity to depreciate it, it seems to be now a new development !! a paid version , ok we have to pay now... but better pay (please be not too expansive) that nothing more after the 01 of december :-) we are waiting hearing from you :-)

    ReplyDelete
  10. Any news on updating the image selection? This is pretty cool, but would be a lot cooler if the result had the actual image file url in it. The page link as the url is only mildly useful.

    ReplyDelete