Skip to content

Commit

Permalink
HTTPS by default
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Aug 28, 2016
1 parent 6ade42e commit 2f0c910
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 30 deletions.
8 changes: 4 additions & 4 deletions README.md
@@ -1,10 +1,10 @@
# [VICOPO](http://vicopo.selfbuild.fr/)
# [VICOPO](https://vicopo.selfbuild.fr/)

#### API HTTP et Script pour trouver les villes à partir d'un code postal et code postaux à partir d'une ville

Vicopo est un moyen léger et rapide rechercher une ville française et implémenter des propositions à la volée, l'autocomplétion d'un champ de ville ou de code postal et la conversion de l'un vers l'autre.

http://vicopo.selfbuild.fr/
https://vicopo.selfbuild.fr/

## Utilisation

Expand Down Expand Up @@ -88,7 +88,7 @@ Les méthodes `$.vicopo()`, `$.codePostal()` et `$.ville()` prennent en premier
| Protocole | URL |
|-----------|-------------------------------------------------------|
| HTTP | http://vicopo.selfbuild.fr/cherche/680 |
| HTTPS | https://www.selfbuild.fr/vicopo/cherche/680 |
| HTTPS | https://vicopo.selfbuild.fr/cherche/680 |
```json
{
"input": "680",
Expand Down Expand Up @@ -121,4 +121,4 @@ vicopo(ville, function (err, cities) {
});
```

Plus d'options sur http://vicopo.selfbuild.fr/
Plus d'options sur https://vicopo.selfbuild.fr/
10 changes: 6 additions & 4 deletions Vicopo/Vicopo.py
Expand Up @@ -2,10 +2,12 @@

class Vicopo:
@staticmethod
def http(search):
response = urllib.urlopen('http://vicopo.selfbuild.fr/search/' + str(search))
def get(search, protocol = 'https'):
response = urllib.urlopen(protocol + '://vicopo.selfbuild.fr/search/' + str(search))
return json.loads(response.read())
@staticmethod
def http(search):
return Vicopo.get(search, 'http')
@staticmethod
def https(search):
response = urllib.urlopen('https://www.selfbuild.fr/vicopo/search/' + str(search))
return json.loads(response.read())
return Vicopo.get(search, 'https')
2 changes: 1 addition & 1 deletion composer.json
@@ -1,7 +1,7 @@
{
"name": "kylekatarnls/vicopo",
"description": "API HTTP et Script pour trouver les villes à partir d'un code postal et code postaux à partir d'une ville",
"homepage": "http://vicopo.selfbuild.fr",
"homepage": "https://vicopo.selfbuild.fr",
"type": "library",
"require": {
"php": ">=5.3.0"
Expand Down
3 changes: 0 additions & 3 deletions exemple.py
@@ -1,6 +1,3 @@
import sys
sys.path.append('./Vicopo/')

from Vicopo import Vicopo

print(Vicopo.http(75001))
Expand Down
6 changes: 3 additions & 3 deletions index.js
@@ -1,11 +1,11 @@
module.exports = function (protocol) {
protocol = protocol || 'http';
var url = 'http://vicopo.selfbuild.fr/search/';
protocol = protocol || 'https';
var url = 'https://vicopo.selfbuild.fr/search/';
switch (protocol) {
case 'https':
url = 'https://www.selfbuild.fr/vicopo/search/';
break;
case 'http':
url = 'http://vicopo.selfbuild.fr/search/';
break;
default:
throw new Error(protocol + ' protocol not supported');
Expand Down
15 changes: 6 additions & 9 deletions lib/vicopo.rb
Expand Up @@ -2,22 +2,19 @@
require 'json'

class Vicopo
def self.http(search)
uri = URI('http://vicopo.selfbuild.fr/search/' + search.to_s)
def self.get(search, protocol = 'https')
uri = URI(protocol + '://vicopo.selfbuild.fr/search/' + search.to_s)
response = JSON.parse(Net::HTTP.get(uri))
if response['cities']
return response['cities']
else
raise 'No valid answear found.'
end
end
def self.http(search)
return self.get(search, 'http')
end
def self.https(search)
uri = URI('https://www.selfbuild.fr/vicopo/search/' + search.to_s)
response = JSON.parse(Net::HTTP.get(uri))
if response['cities']
return response['cities']
else
raise 'No valid answear found.'
end
return self.get(search, 'https')
end
end
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"bugs": {
"url": "https://github.com/kylekatarnls/vicopo/issues"
},
"homepage": "http://vicopo.selfbuild.fr",
"homepage": "https://vicopo.selfbuild.fr",
"dependencies": {
"jquery": ">=1.7.2"
}
Expand Down
8 changes: 4 additions & 4 deletions src/Vicopo/Vicopo.php
Expand Up @@ -4,8 +4,8 @@

class Vicopo {

static protected function get($url, $search) {
$vicopoUrl = $url . urlencode($ville);
static protected function get($search, $protocol = 'https') {
$vicopoUrl = $protocol . '://vicopo.selfbuild.fr/search/' . urlencode($ville);
$json = @json_decode(file_get_contents($vicopoUrl));
if (!is_object($json) || !isset($json->cities)) {
throw new Exception("No valid answear found", 1);
Expand All @@ -14,10 +14,10 @@ static protected function get($url, $search) {
}

static public function http($search) {
return static::get('http://vicopo.selfbuild.fr/search/', $search);
return static::get($search, 'http');
}

static public function https($search) {
return static::get('https://www.selfbuild.fr/vicopo/search/', $search);
return static::get($search, 'https');
}
}
2 changes: 1 addition & 1 deletion vicopo.gemspec
Expand Up @@ -7,6 +7,6 @@ Gem::Specification.new do |s|
s.authors = ["kylekatarnls"]
s.email = 'vicopo@selfbuild.fr'
s.files = ["lib/vicopo.rb"]
s.homepage = 'http://vicopo.selfbuild.fr'
s.homepage = 'https://vicopo.selfbuild.fr'
s.license = 'GNU GPL v3.0'
end

0 comments on commit 2f0c910

Please sign in to comment.