Game Development Reference
In-Depth Information
At irst, we look at the Picasa and Flickr REST APIs to download image lists and form direct
URLs to photos. Then, we get to the thread-safe asynchronous programming and inally
we implement a simple HTTP server for debugging purposes using the pure Berkeley
sockets interface.
The examples of this chapter related to multithreaded programming are Windows-only, but at
the end of the chapter, we shall combine everything to create the Android App5 example with
a built-in web server.
Fetching list of photos from Flickr and
Picasa
In the previous chapter, we built the libcurl library. As a refresher on how to download a web
page, refer to the 1_CurlDownloader example in the accompanying materials for
this chapter.
The information about using Picasa and Flickr in C++ is somewhat limited, but calling the
REST (Representational State Transfer) APIs of these sites is no different from downloading
web pages. All we have to do is form a correct URL for the images list, download an XML ile
from this URL, and then parse this ile to build a list of individual image URLs. Usually, REST
APIs require some form of authentication using oAuth, but for the read-only access, it is
suficient to use only the application key, which is available through the simple
online registration.
The example code in this recipe only forms the URLs and it is up to the
reader to download the actual image list. We also do not provide an
application key here, and we encourage the reader to obtain a key and
test the code.
Getting ready
Every application must sign its requests to the Flickr server with a unique key, obtained
through a simple registration process. An application key and a secret key are long
hexadecimal numbers similar to: 14fc6b12345678901234567890d69c8d . Create your own
Yahoo ID account and obtain application keys at the following site: http://www.flickr.
com/services/api/misc.api_keys.html . If you already have a Yahoo ID account,
proceed directly to http://www.flickr.com/services/apps/create .
The Picasa photo hosting provides free access to the RSS feeds and does not require client
applications to use any authentication keys.
 
Search WWH ::




Custom Search