From 27a0e696701b554c918d30d744a0217a7259e28d Mon Sep 17 00:00:00 2001 From: Alexandre Dutoit Date: Mon, 30 Jul 2012 12:07:19 +0200 Subject: [PATCH 01/13] Add downloadMediaComp method --- php/example.php | 4 ++++ php/fotolia-api.php | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/php/example.php b/php/example.php index eaca174..0e96087 100644 --- a/php/example.php +++ b/php/example.php @@ -22,6 +22,10 @@ } } +// download comp file +$comp_dl_data = $api->getMediaComp(35957426); +$api->downloadMediaComp($comp_dl_data['url'], '/tmp/comp.jpg'); + // loggin in and retrieving user data $api->loginUser('your_login', 'your_password'); print_r($api->getUserData()); diff --git a/php/fotolia-api.php b/php/fotolia-api.php index 47bb2e0..537c57f 100644 --- a/php/fotolia-api.php +++ b/php/fotolia-api.php @@ -314,6 +314,29 @@ public function getMedia($id, $license_name, $subaccount_id = NULL) * @param string $output_file if null the downloaded file will be echoed on standard output */ public function downloadMedia($download_url, $output_file = NULL) + { + return $this->_download($download_url, $output_file); + } + + /** + * Download a media comp and write it to a file if necessary + * + * @param string $download_url URL as returned by getMediaComp() + * @param string $output_file if null the downloaded file will be echoed on standard output + */ + public function downloadMediaComp($download_url, $output_file = NULL) + { + return $this->_download($download_url, $output_file, false); + } + + /** + * Download a content and write it to a file if necessary + * + * @param string $download_url URL + * @param string $output_file if null the downloaded file will be echoed on standard output + * @param bool $http_auth set curl password if needed + */ + private function _download($download_url, $output_file = NULL, $http_auth = true) { $ch = $this->_getCurlHandler($download_url); @@ -327,7 +350,9 @@ public function downloadMedia($download_url, $output_file = NULL) } curl_setopt($ch, CURLOPT_FILE, $output_fd); - curl_setopt($ch, CURLOPT_USERPWD, $this->_getHttpAuth(TRUE, TRUE)); + if ($http_auth) { + curl_setopt($ch, CURLOPT_USERPWD, $this->_getHttpAuth(TRUE, TRUE)); + } $response = curl_exec($ch); From b7a2184a59592bbdd65e22b060d940081092f4a4 Mon Sep 17 00:00:00 2001 From: coderua Date: Mon, 19 Nov 2012 17:29:23 +0200 Subject: [PATCH 02/13] Update README.html Fixed errors in php-example --- README.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.html b/README.html index c0d4ad4..d1da6c1 100644 --- a/README.html +++ b/README.html @@ -713,11 +713,11 @@

PHP

00024: 00025: // loggin in and retrieving user data 00026: $api->loginUser('your_login', 'your_password'); -00027: print_r(api.getUserData()); +00027: print_r($api->getUserData()); 00028: 00029: // purchasing and downloading a file -00030: $dl_data = $api.getMedia(35957426, 'XS'); -00031: $api.downloadMedia($dl_data['url'], '/tmp/' + $dl_data['name']); +00030: $dl_data = $api->getMedia(35957426, 'XS'); +00031: $api->downloadMedia($dl_data['url'], '/tmp/' + $dl_data['name']);

Python

From c69a6d0fb056372b6f562fbc4fdc94f1d5d3e77f Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Tue, 15 Jan 2013 15:14:00 +0100 Subject: [PATCH 03/13] add markdown readme file --- README.md | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..573bcf7 --- /dev/null +++ b/README.md @@ -0,0 +1,211 @@ +Fotolia API Kits +================ +Olivier Sirven +[Fotolia.com](http://www.fotolia.com/ "Fotolia") + +Introduction +============ +Fotolia's industry-leading API allows developers and businesses to +quickly integrate a vast database of images in their workflows and +business models. + +Whether you're developing an application with millions of photos, or +integrating a stock photography library into your business to increase +customer satisfaction, Fotolia's powerful APIs are key. But technical +excellence is only part of the formula – our business development team +will work with you to determine the best way to maximize results. + +Fotolia's API line-up +===================== + +Partner API +----------- +Our Partner API allows you to embed royalty-free image search into +your website. + +* Your customers may search the entire Fotolia library to find images + without leaving your website. +* After finding the perfect image, your customer clicks through to us to + buy. +* Since our Affiliate Program is also built into this API, we + automatically pay you for all revenues generated. + +[Learn more](http://www.fotolia.com/Services/API/Partner "Fotolia Partner API") + +Business API +------------ +Our Business API is for on-demand businesses producing custom +merchandise and products, including web site templates and printed +materials. + +* Your customers will gain access to high-resolution images directly + within your application or web-based tool. +* Wholesale pricing is available. +* You can also use this API to embed Fotolia into your intranet or + application to make search and download faster. + +[Learn more](http://www.fotolia.com/Services/API/Business "Fotolia Business API") + +Reseller API +------------ +Our Reseller API allows you to sell Fotolia's images under your brand name to your customers. + +* Access Fotolia's entire microstock image library, with full search + and download capability. +* A complete white-label solution, available in select markets around + the world. + +[Learn more](http://www.fotolia.com/Services/API/Reseller "Fotolia Reseller API") + +Content of this package +======================= + +This package contains a full implementation of the API for PHP, python +and java. Each provides an example file to show how to use it. + +PHP +--- + +Requirements: + +* [PHP >= 5.2](http://www.php.net) +* [PHP cURL extension](http://www.php.net/curl) + +.Example usage + +
+#!/usr/bin/env php
+getSearchResults(
+    array(
+        'words' => 'car',
+        'language_id' => Fotolia_Api::LANGUAGE_ID_EN_US,
+        'limit' => 1,
+    ));
+
+printf("Found %d results", $results['nb_results']);
+
+foreach ($results as $key => $value) {
+    // iterating only over numeric keys and silently skip other keys
+    if (is_numeric($key)) {
+        printf("matching media ID: %d", $value['id']);
+    }
+}
+
+// loggin in and retrieving user data
+$api->loginUser('your_login', 'your_password');
+print_r($api->getUserData());
+
+// purchasing and downloading a file
+$dl_data = $api->getMedia(35957426, 'XS');
+$api->downloadMedia($dl_data['url'], '/tmp/' . $dl_data['name']);
+
+ +Python +------ + +Requirements: + +* [Python >= 2.7](http://python.org/) +* [pycurl extension](http://pycurl.sourceforge.net/) + + +.Example usage + +
+#!/usr/bin/env python
+
+import fotolia_api
+
+api = fotolia_api.FotoliaApi('your_api_key')
+
+# searching for files
+results = api.get_search_results({'words': 'car', 'language_id': fotolia_api.LANGUAGE_ID_EN_US, 'limit': 1})
+print "Found %d results" % results['nb_results']
+
+for key, value in results.items():
+    try:
+        int(key)
+        print "matching media ID: %d" % value['id']
+    except ValueError:
+        # iterating only over numeric keys and silently skip other keys
+        pass
+
+# loggin in and retrieving user data
+api.login_user('your_login', 'your_password')
+print api.get_user_data()
+
+# purchasing and downloading a file
+dl_data = api.get_media(35957426, 'XS')
+api.download_media(dl_data['url'], '/tmp/' + str(dl_data['name']))
+
+ +Java +---- + +Requirements: + +* [apache common HTTP client](http://hc.apache.org) +* [json simple](http://code.google.com/p/json-simple/) +* [java JDK >= 6.26](http://www.java.com) + +A simple Makefile is provided to help using it. It supports following +commands: + +build:: + Build the entire package + +jar:: + Create a JAR file for easy inclusion + +clean:: + Clean the build files + +example:: + Build the example program + +.Example usage + +
+import org.webservice.fotolia.*;
+import org.json.simple.JSONObject;
+
+public class example
+{
+    public static void main(String[] args)
+    {
+        FotoliaApi client = new FotoliaApi("your_api_key");
+
+        // fetching a media data
+        System.out.println(client.getMediaData(18136053));
+
+        // searching files
+        FotoliaSearchQuery query = new FotoliaSearchQuery();
+        query.setWords("car").setLanguageId(FotoliaApi.LANGUAGE_ID_EN_US).setLimit(1);
+        System.out.println(client.getSearchResults(query));
+
+        // buying and downloading a file
+        try {
+            client.loginUser("your_login", "your_password");
+            JSONObject res = client.getMedia(35957426, "XS");
+            client.downloadMedia((String) res.get("url"), "/tmp/" + (String) res.get("name"));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
+
+ +Informations +------------ +Email: api@fotolia.com + +[Google Groups](http://groups.google.com/group/FotoliaAPI?pli=1 "Fotolia API Google Group") + +[Online Documentation](http://us.fotolia.com/Services/API/Rest/Documentation "Fotolia REST API Documentation") From 8ea09e774dd4a0132ea5c5445bfe23bf416143e1 Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Tue, 15 Jan 2013 15:14:53 +0100 Subject: [PATCH 04/13] remove asciidoc readme file --- README.asciidoc | 136 ------------------------------------------------ 1 file changed, 136 deletions(-) delete mode 100644 README.asciidoc diff --git a/README.asciidoc b/README.asciidoc deleted file mode 100644 index 9995793..0000000 --- a/README.asciidoc +++ /dev/null @@ -1,136 +0,0 @@ -Fotolia API Kits -================ -Olivier Sirven -:website: http://www.fotolia.com/ - -Introduction ------------- -Fotolia’s industry-leading API allows developers and businesses to -quickly integrate a vast database of images in their workflows and -business models. - -Whether you’re developing an application with millions of photos, or -integrating a stock photography library into your business to increase -customer satisfaction, Fotolia’s powerful APIs are key. But technical -excellence is only part of the formula – our business development team -will work with you to determine the best way to maximize results. - -Fotolia’s API line-up ---------------------- - -Partner API -~~~~~~~~~~~ -Our Partner API allows you to embed royalty-free image search into -your website. - -- Your customers may search the entire Fotolia library to find images - without leaving your website. -- After finding the perfect image, your customer clicks through to us to - buy. -- Since our Affiliate Program is also built into this API, we - automatically pay you for all revenues generated. - -http://www.fotolia.com/Services/API/Partner[Learn more] - -Business API -~~~~~~~~~~~~ -Our Business API is for on-demand businesses producing custom -merchandise and products, including web site templates and printed -materials. - -- Your customers will gain access to high-resolution images directly - within your application or web-based tool. -- Wholesale pricing is available. -- You can also use this API to embed Fotolia into your intranet or - application to make search and download faster. - -http://www.fotolia.com/Services/API/Business[Learn more] - -Reseller API -~~~~~~~~~~~~ -Our Reseller API allows you to sell Fotolia’s images under your brand name to your customers. - -- Access Fotolia’s entire microstock image library, with full search - and download capability. -- A complete white-label solution, available in select markets around - the world. - -http://www.fotolia.com/Services/API/Reseller[Learn more] - -Content of this package ------------------------ - -This package contains a full implementation of the API for PHP, python -and java. Each provides an example file to show how to use it. - -PHP -~~~ - -Requirements: - -- http://www.php.net[PHP >= 5.2] -- http://www.php.net/curl[PHP cURL extension] - -.Example usage - -[source,php,numbered] -------------------------------------------- -include::php/example.php[] -------------------------------------------- - - -Python -~~~~~~ - -Requirements: - -- http://python.org/[Python >= 2.7] -- http://pycurl.sourceforge.net/[pycurl extension] - - -.Example usage - -[source,python,numbered] -------------------------------------------- -include::python/example.py[] -------------------------------------------- - - -Java -~~~~ - -Requirements: - -- http://hc.apache.org[apache common HTTP client] -- http://code.google.com/p/json-simple/[json simple] -- http://www.java.com[java JDK >= 6.26] - -A simple Makefile is provided to help using it. It supports following -commands: - -build:: - Build the entire package - -jar:: - Create a JAR file for easy inclusion - -clean:: - Clean the build files - -example:: - Build the example program - -.Example usage - -[source,java,numbered] ------------------------- -include::java/example.java[] ------------------------- - -Informations ------------- -Email: api@fotolia.com - -http://groups.google.com/group/FotoliaAPI?pli=1[Google Groups] - -http://us.fotolia.com/Services/API/Rest/Documentation[Online Documentation] From 2db25ea4b282b8b81c7791983310377846a1cd18 Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Tue, 5 Feb 2013 16:50:36 +0100 Subject: [PATCH 05/13] fix code from last merge --- php/fotolia-api.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/php/fotolia-api.php b/php/fotolia-api.php index c931f53..e150aaf 100644 --- a/php/fotolia-api.php +++ b/php/fotolia-api.php @@ -336,7 +336,7 @@ public function downloadMediaComp($download_url, $output_file = NULL) * @param string $output_file if null the downloaded file will be echoed on standard output * @param bool $http_auth set curl password if needed */ - private function _download($download_url, $output_file = NULL, $http_auth = true) + private function _download($download_url, $output_file = NULL, $http_auth_required = true) { $ch = $this->_getCurlHandler($download_url); @@ -350,9 +350,7 @@ private function _download($download_url, $output_file = NULL, $http_auth = true } curl_setopt($ch, CURLOPT_FILE, $output_fd); - if ($http_auth) { - curl_setopt($ch, CURLOPT_USERPWD, $this->_getHttpAuth(TRUE, TRUE)); - } + curl_setopt($ch, CURLOPT_USERPWD, $this->_getHttpAuth(TRUE, $http_auth_required)); $response = curl_exec($ch); From a15aaea74b0d6d82a4ad442cd33fb1b2def57338 Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Tue, 5 Feb 2013 16:58:25 +0100 Subject: [PATCH 06/13] fix _download() private to work in http embed mode --- php/fotolia-api.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/php/fotolia-api.php b/php/fotolia-api.php index e150aaf..b891ebb 100644 --- a/php/fotolia-api.php +++ b/php/fotolia-api.php @@ -341,7 +341,11 @@ private function _download($download_url, $output_file = NULL, $http_auth_requir $ch = $this->_getCurlHandler($download_url); if ($output_file === NULL) { - $output_file = 'php://stdout'; + if ($this->_isShellMode()) { + $output_file = 'php://stdout'; + } else { + $output_file = 'php://output'; + } } $output_fd = fopen($output_file, 'w'); @@ -1122,6 +1126,14 @@ private function _isPostMethod($method) return $is_post_method; } + + /* + * Define if the api is called in CLI mode + */ + private function _isShellMode() + { + return !empty($_SERVER['SHELL']); + } } /** From aabc3e8d8472b6cc19416404fd910ae22238f062 Mon Sep 17 00:00:00 2001 From: defro Date: Thu, 14 Feb 2013 14:47:06 +0100 Subject: [PATCH 07/13] Add method getSeasonalGalleries There is a problem with arg theme_id : cannot to be set to 0 (zero) for get all galleries. So script will added it to args if the $theme_id is more than 0 --- php/fotolia-api.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/php/fotolia-api.php b/php/fotolia-api.php index b891ebb..3c17510 100644 --- a/php/fotolia-api.php +++ b/php/fotolia-api.php @@ -201,6 +201,23 @@ public function getGalleries($language_id = Fotolia_Api::LANGUAGE_ID_EN_US) )); } + /** + * This method returns public seasonal galleries for a defined language + * + * @param int $language_id + * @return array + */ + public function getSeasonalGalleries($language_id = Fotolia_Api::LANGUAGE_ID_EN_US, $thumbnail_size = 110, $theme_id = 0) + { + $args = array( + 'language_id' => $language_id + ,'thumbnail_size' => $thumbnail_size + ); + if ((int)$theme_id > 0) $args['theme_id'] = $theme_id; + + return $this->_api('getSeasonalGalleries', $args); + } + /** * This method returns Fotolia list of countries. * @@ -944,6 +961,7 @@ protected function _getNamespace($method) case 'getCategories2': case 'getTags': case 'getGalleries': + case 'getSeasonalGalleries': case 'getCountries': return 'search'; From 8b53829fb060415d95311fe95e42c93c262333f5 Mon Sep 17 00:00:00 2001 From: defro Date: Tue, 19 Feb 2013 15:22:53 +0100 Subject: [PATCH 08/13] rewrite method getSeasonalGalleries in PHP Kit rewrite $args array $theme_id set default to null --- php/fotolia-api.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/php/fotolia-api.php b/php/fotolia-api.php index 3c17510..1c86190 100644 --- a/php/fotolia-api.php +++ b/php/fotolia-api.php @@ -207,15 +207,14 @@ public function getGalleries($language_id = Fotolia_Api::LANGUAGE_ID_EN_US) * @param int $language_id * @return array */ - public function getSeasonalGalleries($language_id = Fotolia_Api::LANGUAGE_ID_EN_US, $thumbnail_size = 110, $theme_id = 0) + public function getSeasonalGalleries($language_id = Fotolia_Api::LANGUAGE_ID_EN_US, $thumbnail_size = 110, $theme_id = null) { - $args = array( - 'language_id' => $language_id - ,'thumbnail_size' => $thumbnail_size - ); - if ((int)$theme_id > 0) $args['theme_id'] = $theme_id; - - return $this->_api('getSeasonalGalleries', $args); + return $this->_api('getSeasonalGalleries', + array( + 'language_id' => $language_id, + 'thumbnail_size' => $thumbnail_size, + 'theme_id' => $theme_id + )); } /** From 77852cd8e7528ecc64deff611aa4155d84f6004a Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Mon, 22 Apr 2013 11:04:50 +0200 Subject: [PATCH 09/13] fix indentation --- php/fotolia-api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php/fotolia-api.php b/php/fotolia-api.php index 1c86190..6b9b152 100644 --- a/php/fotolia-api.php +++ b/php/fotolia-api.php @@ -211,9 +211,9 @@ public function getSeasonalGalleries($language_id = Fotolia_Api::LANGUAGE_ID_EN_ { return $this->_api('getSeasonalGalleries', array( - 'language_id' => $language_id, - 'thumbnail_size' => $thumbnail_size, - 'theme_id' => $theme_id + 'language_id' => $language_id, + 'thumbnail_size' => $thumbnail_size, + 'theme_id' => $theme_id )); } From 5234fdf4b6f221814e9283dbe0115d389248c5db Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Mon, 22 Apr 2013 11:10:07 +0200 Subject: [PATCH 10/13] add getSeasonalGalleries API call support --- python/fotolia_api/rest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/python/fotolia_api/rest.py b/python/fotolia_api/rest.py index 8ac3119..88f9cc9 100644 --- a/python/fotolia_api/rest.py +++ b/python/fotolia_api/rest.py @@ -113,6 +113,21 @@ def get_galleries(self, language_id = fotolia_api.LANGUAGE_ID_EN_US): return self._api('getGalleries', params) + def get_seasonal_galleries(self, language_id = fotolia_api.LANGUAGE_ID_EN_US, thumbnail_size = fotolia_api.THUMB_SIZE_SMALL, theme_id = None): + """ + This method returns public galleries for a defined language + """ + + params = { + 'language_id': language_id, + 'thumbnail_size': thumbnail_size + } + + if theme_id != None: + params['theme_id'] = theme_id + + return self._api('getSeasonalGalleries', params) + def get_countries(self, language_id = fotolia_api.LANGUAGE_ID_EN_US): """ This method returns Fotolia list of countries @@ -735,6 +750,7 @@ def _get_namespace(self, method): method == 'getCategories2' or \ method == 'getTags' or \ method == 'getGalleries' or \ + method == 'getSeasonalGalleries' or \ method == 'getCountries': return 'search' From 2ed7809a6d8b837ad0378176e7d5d9226ec4786d Mon Sep 17 00:00:00 2001 From: Olivier Sirven Date: Sat, 1 Jun 2013 12:29:09 +0200 Subject: [PATCH 11/13] fix html code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 573bcf7..b3eb64e 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Requirements:
 #!/usr/bin/env php
-
Date: Tue, 9 Sep 2014 12:16:19 +0200
Subject: [PATCH 12/13] SSL is now the only way to consume the REST API

---
 java/org/webservice/fotolia/FotoliaApi.java | 31 ++------------------
 php/fotolia-api.php                         | 32 ++-------------------
 python/fotolia_api/__init__.py              |  2 +-
 python/fotolia_api/rest.py                  | 19 ++----------
 4 files changed, 9 insertions(+), 75 deletions(-)

diff --git a/java/org/webservice/fotolia/FotoliaApi.java b/java/org/webservice/fotolia/FotoliaApi.java
index cf3ea41..9a86807 100644
--- a/java/org/webservice/fotolia/FotoliaApi.java
+++ b/java/org/webservice/fotolia/FotoliaApi.java
@@ -31,7 +31,7 @@
 
 public class FotoliaApi
 {
-    public static String REST_URI = "api.fotolia.com/Rest";
+    public static String REST_URI = "https://api.fotolia.com/Rest";
 
     public static String REST_VERSION = "1";
 
@@ -68,11 +68,6 @@ public class FotoliaApi
      */
     private final String _api_key;
 
-    /**
-     * HTTPs mode flag
-     */
-    private boolean _use_https;
-
     /**
      * Current session ID
      */
@@ -98,12 +93,10 @@ public FotoliaApi(final String api_key)
      * Constructor
      *
      * @param  api_key
-     * @param  use_https
      */
-    public FotoliaApi(final String api_key, final boolean use_https)
+    public FotoliaApi(final String api_key)
     {
         this._api_key = api_key;
-        this.setHttpsMode(use_https);
     }
 
     /**
@@ -116,18 +109,6 @@ public String getApiKey()
         return this._api_key;
     }
 
-    /**
-     * Sets the HTTPs mode flag
-     *
-     * @param  flag
-     * @return FotoliaApi
-     */
-    public FotoliaApi setHttpsMode(final boolean flag)
-    {
-        this._use_https = flag;
-        return this;
-    }
-
     /**
      * Fotolia API test mode
      *
@@ -1431,13 +1412,7 @@ private String _getUri(final String method_name, final FotoliaApiArgs args)
             namespace += "/";
         }
 
-        uri = "http";
-
-        if (this._use_https) {
-            uri += 's';
-        }
-
-        uri += "://" + FotoliaApi.REST_URI + "/" + FotoliaApi.REST_VERSION + "/" + namespace + method_name;
+        uri = FotoliaApi.REST_URI + "/" + FotoliaApi.REST_VERSION + "/" + namespace + method_name;
 
         if (args != null) {
             uri += "?" + args;
diff --git a/php/fotolia-api.php b/php/fotolia-api.php
index 6b9b152..fbbad97 100644
--- a/php/fotolia-api.php
+++ b/php/fotolia-api.php
@@ -22,7 +22,7 @@ class Fotolia_Api
     /**
      * Fotolia REST uri
      */
-    const FOTOLIA_REST_URI = 'api.fotolia.com/Rest';
+    const FOTOLIA_REST_URI = 'https://api.fotolia.com/Rest';
 
     /**
      * Fotolia REST API version
@@ -65,11 +65,6 @@ class Fotolia_Api
      */
     private $_api_key;
 
-    /**
-     * HTTPs mode flag
-     */
-    private $_use_https;
-
     /**
      * Current session id
      *
@@ -89,12 +84,11 @@ class Fotolia_Api
      *
      * @param  string $api_key
      */
-    public function __construct($api_key, $use_https = FALSE)
+    public function __construct($api_key)
     {
         $this->_api_key = $api_key;
         $this->_session_id = NULL;
         $this->_session_id_timestamp = NULL;
-        $this->_use_https = $use_https;
     }
 
     /**
@@ -107,15 +101,6 @@ public function getApiKey()
         return $this->_api_key;
     }
 
-    /**
-     * Toggle HTTPS
-     */
-    public function setHttpsMode($flag)
-    {
-        $this->_use_https = $flag;
-        return $this;
-    }
-
     /**
      * This method makes possible to search media in fotolia image bank.
      * Full search capabilities are available through the API
@@ -434,21 +419,12 @@ public function getMediaComp($id)
      */
     public function loginUser($login, $pass)
     {
-        $old_https_flag = $this->_use_https;
-        if (!$old_https_flag) {
-            $this->setHttpsMode(true);
-        }
-
         $res = $this->_api('loginUser',
                              array(
                                  'login' => $login,
                                  'pass' => $pass,
                              ));
 
-        if (!$old_https_flag) {
-            $this->setHttpsMode(false);
-        }
-
         $this->_session_id = $res['session_token'];
         $this->_session_id_timestamp = time();
     }
@@ -1042,14 +1018,12 @@ protected function _getSessionId($auto_refresh_token = TRUE)
      */
     private function _getFullURI($method, array $query = NULL)
     {
-        $scheme = $this->_use_https ? 'https' : 'http';
-
         $namespace = $this->_getNamespace($method);
         if (!empty($namespace)) {
             $namespace .= '/';
         }
 
-        $uri = $scheme . '://' . Fotolia_Api::FOTOLIA_REST_URI . '/'
+        $uri = Fotolia_Api::FOTOLIA_REST_URI . '/'
             . Fotolia_Api::FOTOLIA_REST_VERSION . '/' . $namespace . $method;
 
         if ($query !== NULL) {
diff --git a/python/fotolia_api/__init__.py b/python/fotolia_api/__init__.py
index 0005926..f76d813 100644
--- a/python/fotolia_api/__init__.py
+++ b/python/fotolia_api/__init__.py
@@ -1,4 +1,4 @@
-REST_URI = "api.fotolia.com/Rest"
+REST_URI = "https://api.fotolia.com/Rest"
 REST_VERSION = "1"
 
 LANGUAGE_ID_FR_FR = 1
diff --git a/python/fotolia_api/rest.py b/python/fotolia_api/rest.py
index 88f9cc9..818a54d 100644
--- a/python/fotolia_api/rest.py
+++ b/python/fotolia_api/rest.py
@@ -15,22 +15,18 @@ class Rest:
     # api key
     _api_key = None
 
-    # https toggle flag
-    _use_https = False
-
     # session ID if any
     _session_id = None
 
     # session ID timestamp if any
     _session_id_timestamp = None
 
-    def __init__(self, api_key, use_https = False):
+    def __init__(self, api_key):
         """
         Constructor
         """
 
         self._api_key = api_key
-        self._use_https = use_https
         self._session_id = None
         self._session_id_timestamp = None
 
@@ -41,13 +37,6 @@ def get_api_key(self):
 
         return self._api_key
 
-    def set_https_mode(self, flag):
-        """
-        Toggle HTTPS
-        """
-
-        self._use_https = flag
-
     def get_search_results(self, search_params, result_columns = []):
         """
         This method makes possible to search media in fotolia image bank.
@@ -722,17 +711,13 @@ def _get_full_uri(self, method, query = None):
         Generate the full URI to use for API calls
         """
 
-        scheme = 'http'
-        if self._use_https:
-            scheme += 's'
-
         namespace = self._get_namespace(method)
         if namespace != None:
             namespace += '/'
         else:
             namespace = ''
 
-        uri = scheme + '://' + fotolia_api.REST_URI + '/' + fotolia_api.REST_VERSION + '/' + namespace + method
+        uri = fotolia_api.REST_URI + '/' + fotolia_api.REST_VERSION + '/' + namespace + method
 
         if query != None:
             uri += '?' + self._recursive_urlencode(query)

From 938b15596c002fe7303388d305486a577b14a263 Mon Sep 17 00:00:00 2001
From: Reguy Epolo 
Date: Wed, 30 Nov 2016 12:25:48 +0100
Subject: [PATCH 13/13] Add Curl follow redirect option

---
 php/fotolia-api.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/php/fotolia-api.php b/php/fotolia-api.php
index fbbad97..1790676 100644
--- a/php/fotolia-api.php
+++ b/php/fotolia-api.php
@@ -356,6 +356,7 @@ private function _download($download_url, $output_file = NULL, $http_auth_requir
 
         curl_setopt($ch, CURLOPT_FILE, $output_fd);
         curl_setopt($ch, CURLOPT_USERPWD, $this->_getHttpAuth(TRUE, $http_auth_required));
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
 
         $response = curl_exec($ch);