|
| 1 | +Fotolia API Kits |
| 2 | +================ |
| 3 | +Olivier Sirven <olivier@fotolia.com> |
| 4 | +[Fotolia.com](http://www.fotolia.com/ "Fotolia") |
| 5 | + |
| 6 | +Introduction |
| 7 | +============ |
| 8 | +Fotolia's industry-leading API allows developers and businesses to |
| 9 | +quickly integrate a vast database of images in their workflows and |
| 10 | +business models. |
| 11 | + |
| 12 | +Whether you're developing an application with millions of photos, or |
| 13 | +integrating a stock photography library into your business to increase |
| 14 | +customer satisfaction, Fotolia's powerful APIs are key. But technical |
| 15 | +excellence is only part of the formula – our business development team |
| 16 | +will work with you to determine the best way to maximize results. |
| 17 | + |
| 18 | +Fotolia's API line-up |
| 19 | +===================== |
| 20 | + |
| 21 | +Partner API |
| 22 | +----------- |
| 23 | +Our Partner API allows you to embed royalty-free image search into |
| 24 | +your website. |
| 25 | + |
| 26 | +* Your customers may search the entire Fotolia library to find images |
| 27 | + without leaving your website. |
| 28 | +* After finding the perfect image, your customer clicks through to us to |
| 29 | + buy. |
| 30 | +* Since our Affiliate Program is also built into this API, we |
| 31 | + automatically pay you for all revenues generated. |
| 32 | + |
| 33 | +[Learn more](http://www.fotolia.com/Services/API/Partner "Fotolia Partner API") |
| 34 | + |
| 35 | +Business API |
| 36 | +------------ |
| 37 | +Our Business API is for on-demand businesses producing custom |
| 38 | +merchandise and products, including web site templates and printed |
| 39 | +materials. |
| 40 | + |
| 41 | +* Your customers will gain access to high-resolution images directly |
| 42 | + within your application or web-based tool. |
| 43 | +* Wholesale pricing is available. |
| 44 | +* You can also use this API to embed Fotolia into your intranet or |
| 45 | + application to make search and download faster. |
| 46 | + |
| 47 | +[Learn more](http://www.fotolia.com/Services/API/Business "Fotolia Business API") |
| 48 | + |
| 49 | +Reseller API |
| 50 | +------------ |
| 51 | +Our Reseller API allows you to sell Fotolia's images under your brand name to your customers. |
| 52 | + |
| 53 | +* Access Fotolia's entire microstock image library, with full search |
| 54 | + and download capability. |
| 55 | +* A complete white-label solution, available in select markets around |
| 56 | + the world. |
| 57 | + |
| 58 | +[Learn more](http://www.fotolia.com/Services/API/Reseller "Fotolia Reseller API") |
| 59 | + |
| 60 | +Content of this package |
| 61 | +======================= |
| 62 | + |
| 63 | +This package contains a full implementation of the API for PHP, python |
| 64 | +and java. Each provides an example file to show how to use it. |
| 65 | + |
| 66 | +PHP |
| 67 | +--- |
| 68 | + |
| 69 | +Requirements: |
| 70 | + |
| 71 | +* [PHP >= 5.2](http://www.php.net) |
| 72 | +* [PHP cURL extension](http://www.php.net/curl) |
| 73 | + |
| 74 | +.Example usage |
| 75 | + |
| 76 | +<pre> |
| 77 | +#!/usr/bin/env php |
| 78 | +<?php |
| 79 | +
|
| 80 | +require_once 'fotolia-api.php'; |
| 81 | +
|
| 82 | +$api = new Fotolia_Api('your_api_key'); |
| 83 | +
|
| 84 | +// searching for files |
| 85 | +$results = $api->getSearchResults( |
| 86 | + array( |
| 87 | + 'words' => 'car', |
| 88 | + 'language_id' => Fotolia_Api::LANGUAGE_ID_EN_US, |
| 89 | + 'limit' => 1, |
| 90 | + )); |
| 91 | + |
| 92 | +printf("Found %d results", $results['nb_results']); |
| 93 | + |
| 94 | +foreach ($results as $key => $value) { |
| 95 | + // iterating only over numeric keys and silently skip other keys |
| 96 | + if (is_numeric($key)) { |
| 97 | + printf("matching media ID: %d", $value['id']); |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +// loggin in and retrieving user data |
| 102 | +$api->loginUser('your_login', 'your_password'); |
| 103 | +print_r($api->getUserData()); |
| 104 | + |
| 105 | +// purchasing and downloading a file |
| 106 | +$dl_data = $api->getMedia(35957426, 'XS'); |
| 107 | +$api->downloadMedia($dl_data['url'], '/tmp/' . $dl_data['name']); |
| 108 | +</pre> |
| 109 | + |
| 110 | +Python |
| 111 | +------ |
| 112 | + |
| 113 | +Requirements: |
| 114 | + |
| 115 | +* [Python >= 2.7](http://python.org/) |
| 116 | +* [pycurl extension](http://pycurl.sourceforge.net/) |
| 117 | + |
| 118 | + |
| 119 | +.Example usage |
| 120 | + |
| 121 | +<pre> |
| 122 | +#!/usr/bin/env python |
| 123 | + |
| 124 | +import fotolia_api |
| 125 | + |
| 126 | +api = fotolia_api.FotoliaApi('your_api_key') |
| 127 | + |
| 128 | +# searching for files |
| 129 | +results = api.get_search_results({'words': 'car', 'language_id': fotolia_api.LANGUAGE_ID_EN_US, 'limit': 1}) |
| 130 | +print "Found %d results" % results['nb_results'] |
| 131 | + |
| 132 | +for key, value in results.items(): |
| 133 | + try: |
| 134 | + int(key) |
| 135 | + print "matching media ID: %d" % value['id'] |
| 136 | + except ValueError: |
| 137 | + # iterating only over numeric keys and silently skip other keys |
| 138 | + pass |
| 139 | + |
| 140 | +# loggin in and retrieving user data |
| 141 | +api.login_user('your_login', 'your_password') |
| 142 | +print api.get_user_data() |
| 143 | + |
| 144 | +# purchasing and downloading a file |
| 145 | +dl_data = api.get_media(35957426, 'XS') |
| 146 | +api.download_media(dl_data['url'], '/tmp/' + str(dl_data['name'])) |
| 147 | +</pre> |
| 148 | + |
| 149 | +Java |
| 150 | +---- |
| 151 | + |
| 152 | +Requirements: |
| 153 | + |
| 154 | +* [apache common HTTP client](http://hc.apache.org) |
| 155 | +* [json simple](http://code.google.com/p/json-simple/) |
| 156 | +* [java JDK >= 6.26](http://www.java.com) |
| 157 | + |
| 158 | +A simple Makefile is provided to help using it. It supports following |
| 159 | +commands: |
| 160 | + |
| 161 | +build:: |
| 162 | + Build the entire package |
| 163 | + |
| 164 | +jar:: |
| 165 | + Create a JAR file for easy inclusion |
| 166 | + |
| 167 | +clean:: |
| 168 | + Clean the build files |
| 169 | + |
| 170 | +example:: |
| 171 | + Build the example program |
| 172 | + |
| 173 | +.Example usage |
| 174 | + |
| 175 | +<pre> |
| 176 | +import org.webservice.fotolia.*; |
| 177 | +import org.json.simple.JSONObject; |
| 178 | + |
| 179 | +public class example |
| 180 | +{ |
| 181 | + public static void main(String[] args) |
| 182 | + { |
| 183 | + FotoliaApi client = new FotoliaApi("your_api_key"); |
| 184 | + |
| 185 | + // fetching a media data |
| 186 | + System.out.println(client.getMediaData(18136053)); |
| 187 | + |
| 188 | + // searching files |
| 189 | + FotoliaSearchQuery query = new FotoliaSearchQuery(); |
| 190 | + query.setWords("car").setLanguageId(FotoliaApi.LANGUAGE_ID_EN_US).setLimit(1); |
| 191 | + System.out.println(client.getSearchResults(query)); |
| 192 | + |
| 193 | + // buying and downloading a file |
| 194 | + try { |
| 195 | + client.loginUser("your_login", "your_password"); |
| 196 | + JSONObject res = client.getMedia(35957426, "XS"); |
| 197 | + client.downloadMedia((String) res.get("url"), "/tmp/" + (String) res.get("name")); |
| 198 | + } catch (Exception e) { |
| 199 | + e.printStackTrace(); |
| 200 | + } |
| 201 | + } |
| 202 | +} |
| 203 | +</pre> |
| 204 | + |
| 205 | +Informations |
| 206 | +------------ |
| 207 | +Email: api@fotolia.com |
| 208 | + |
| 209 | +[Google Groups](http://groups.google.com/group/FotoliaAPI?pli=1 "Fotolia API Google Group") |
| 210 | + |
| 211 | +[Online Documentation](http://us.fotolia.com/Services/API/Rest/Documentation "Fotolia REST API Documentation") |
0 commit comments