Skip to content

Commit 08a46b6

Browse files
committed
SSL is now the only way to consume the REST API
1 parent c49a976 commit 08a46b6

File tree

4 files changed

+9
-75
lines changed

4 files changed

+9
-75
lines changed

java/org/webservice/fotolia/FotoliaApi.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public class FotoliaApi
3333
{
34-
public static String REST_URI = "api.fotolia.com/Rest";
34+
public static String REST_URI = "https://api.fotolia.com/Rest";
3535

3636
public static String REST_VERSION = "1";
3737

@@ -68,11 +68,6 @@ public class FotoliaApi
6868
*/
6969
private final String _api_key;
7070

71-
/**
72-
* HTTPs mode flag
73-
*/
74-
private boolean _use_https;
75-
7671
/**
7772
* Current session ID
7873
*/
@@ -98,12 +93,10 @@ public FotoliaApi(final String api_key)
9893
* Constructor
9994
*
10095
* @param api_key
101-
* @param use_https
10296
*/
103-
public FotoliaApi(final String api_key, final boolean use_https)
97+
public FotoliaApi(final String api_key)
10498
{
10599
this._api_key = api_key;
106-
this.setHttpsMode(use_https);
107100
}
108101

109102
/**
@@ -116,18 +109,6 @@ public String getApiKey()
116109
return this._api_key;
117110
}
118111

119-
/**
120-
* Sets the HTTPs mode flag
121-
*
122-
* @param flag
123-
* @return FotoliaApi
124-
*/
125-
public FotoliaApi setHttpsMode(final boolean flag)
126-
{
127-
this._use_https = flag;
128-
return this;
129-
}
130-
131112
/**
132113
* Fotolia API test mode
133114
*
@@ -1431,13 +1412,7 @@ private String _getUri(final String method_name, final FotoliaApiArgs args)
14311412
namespace += "/";
14321413
}
14331414

1434-
uri = "http";
1435-
1436-
if (this._use_https) {
1437-
uri += 's';
1438-
}
1439-
1440-
uri += "://" + FotoliaApi.REST_URI + "/" + FotoliaApi.REST_VERSION + "/" + namespace + method_name;
1415+
uri = FotoliaApi.REST_URI + "/" + FotoliaApi.REST_VERSION + "/" + namespace + method_name;
14411416

14421417
if (args != null) {
14431418
uri += "?" + args;

php/fotolia-api.php

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Fotolia_Api
2222
/**
2323
* Fotolia REST uri
2424
*/
25-
const FOTOLIA_REST_URI = 'api.fotolia.com/Rest';
25+
const FOTOLIA_REST_URI = 'https://api.fotolia.com/Rest';
2626

2727
/**
2828
* Fotolia REST API version
@@ -65,11 +65,6 @@ class Fotolia_Api
6565
*/
6666
private $_api_key;
6767

68-
/**
69-
* HTTPs mode flag
70-
*/
71-
private $_use_https;
72-
7368
/**
7469
* Current session id
7570
*
@@ -89,12 +84,11 @@ class Fotolia_Api
8984
*
9085
* @param string $api_key
9186
*/
92-
public function __construct($api_key, $use_https = FALSE)
87+
public function __construct($api_key)
9388
{
9489
$this->_api_key = $api_key;
9590
$this->_session_id = NULL;
9691
$this->_session_id_timestamp = NULL;
97-
$this->_use_https = $use_https;
9892
}
9993

10094
/**
@@ -107,15 +101,6 @@ public function getApiKey()
107101
return $this->_api_key;
108102
}
109103

110-
/**
111-
* Toggle HTTPS
112-
*/
113-
public function setHttpsMode($flag)
114-
{
115-
$this->_use_https = $flag;
116-
return $this;
117-
}
118-
119104
/**
120105
* This method makes possible to search media in fotolia image bank.
121106
* Full search capabilities are available through the API
@@ -434,21 +419,12 @@ public function getMediaComp($id)
434419
*/
435420
public function loginUser($login, $pass)
436421
{
437-
$old_https_flag = $this->_use_https;
438-
if (!$old_https_flag) {
439-
$this->setHttpsMode(true);
440-
}
441-
442422
$res = $this->_api('loginUser',
443423
array(
444424
'login' => $login,
445425
'pass' => $pass,
446426
));
447427

448-
if (!$old_https_flag) {
449-
$this->setHttpsMode(false);
450-
}
451-
452428
$this->_session_id = $res['session_token'];
453429
$this->_session_id_timestamp = time();
454430
}
@@ -1042,14 +1018,12 @@ protected function _getSessionId($auto_refresh_token = TRUE)
10421018
*/
10431019
private function _getFullURI($method, array $query = NULL)
10441020
{
1045-
$scheme = $this->_use_https ? 'https' : 'http';
1046-
10471021
$namespace = $this->_getNamespace($method);
10481022
if (!empty($namespace)) {
10491023
$namespace .= '/';
10501024
}
10511025

1052-
$uri = $scheme . '://' . Fotolia_Api::FOTOLIA_REST_URI . '/'
1026+
$uri = Fotolia_Api::FOTOLIA_REST_URI . '/'
10531027
. Fotolia_Api::FOTOLIA_REST_VERSION . '/' . $namespace . $method;
10541028

10551029
if ($query !== NULL) {

python/fotolia_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REST_URI = "api.fotolia.com/Rest"
1+
REST_URI = "https://api.fotolia.com/Rest"
22
REST_VERSION = "1"
33

44
LANGUAGE_ID_FR_FR = 1

python/fotolia_api/rest.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ class Rest:
1515
# api key
1616
_api_key = None
1717

18-
# https toggle flag
19-
_use_https = False
20-
2118
# session ID if any
2219
_session_id = None
2320

2421
# session ID timestamp if any
2522
_session_id_timestamp = None
2623

27-
def __init__(self, api_key, use_https = False):
24+
def __init__(self, api_key):
2825
"""
2926
Constructor
3027
"""
3128

3229
self._api_key = api_key
33-
self._use_https = use_https
3430
self._session_id = None
3531
self._session_id_timestamp = None
3632

@@ -41,13 +37,6 @@ def get_api_key(self):
4137

4238
return self._api_key
4339

44-
def set_https_mode(self, flag):
45-
"""
46-
Toggle HTTPS
47-
"""
48-
49-
self._use_https = flag
50-
5140
def get_search_results(self, search_params, result_columns = []):
5241
"""
5342
This method makes possible to search media in fotolia image bank.
@@ -722,17 +711,13 @@ def _get_full_uri(self, method, query = None):
722711
Generate the full URI to use for API calls
723712
"""
724713

725-
scheme = 'http'
726-
if self._use_https:
727-
scheme += 's'
728-
729714
namespace = self._get_namespace(method)
730715
if namespace != None:
731716
namespace += '/'
732717
else:
733718
namespace = ''
734719

735-
uri = scheme + '://' + fotolia_api.REST_URI + '/' + fotolia_api.REST_VERSION + '/' + namespace + method
720+
uri = fotolia_api.REST_URI + '/' + fotolia_api.REST_VERSION + '/' + namespace + method
736721

737722
if query != None:
738723
uri += '?' + self._recursive_urlencode(query)

0 commit comments

Comments
 (0)