-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzip_search.php
50 lines (46 loc) · 1.69 KB
/
zip_search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$find = $_POST['city'];
try {
//php-soap must be in the list of installed PHP modules!!!
$client = new SoapClient( 'https://total-service.etocrm.fr/ReferentialPlateformService.svc?wsdl',array('trace' => true) );
/* echo "<pre>";
print_r($client->__getTypes());
print_r($client->__getFunctions());
echo "</pre>";
die();*/
//CREDENTIALS
$profileName = 'DceReferential'; //Profile name is inserted here
$key = 'LDZ)q03dkaMQ'; //Private Key is inserted here
$salt = uniqid('',true);
$token = hash('sha256',$salt.$key);
$params = [
'serviceProfilName' => $profileName,
'saltKey' => $salt,
'token' => $token,
'requestInfos' => [
'LocationArgType' => 'City',
'LocationValue' => $find
]
];
$response = $client->RetrieveCRMCityPostalCodeList($params);
$data = $response->RetrieveCRMCityPostalCodeListResult->CityPostalCodeList->CityPostalCodeDataContract;
$postals = [];
foreach ($data AS $info) {
if ($info->City == $find) {
$postals[] = $info->PostalCode;
}
}
header('Content-Type: application/json');
print(json_encode(array_unique($postals)));
} catch (\Exception $e) {
//http_response_code(500);
print $e->detail->ServiceFaultContract->FaultExceptionMessage;
/* if (
(intval($e->detail->ServiceFaultContract->FaultExceptionCode) >= 0 && intval($e->detail->ServiceFaultContract->FaultExceptionCode) <= 29 ) ||
(intval($e->detail->ServiceFaultContract->FaultExceptionCode) == 104)
){
print($e->detail->ServiceFaultContract->FaultExceptionMessage);
} else {
print($technicalErrorMessage);
}*/
}