-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson4.php
51 lines (39 loc) · 1.94 KB
/
json4.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
51
<?php
/* API Proxy for Lab ID */
header('Access-Control-Allow-Origin: *');
$primacyagency = $_GET['pa'];
$post_url = '[ENDPOINT URL]/ref-data/legal-entity/'.$primacyagency.'/lab';
/* Set Basic Autentication Username & Password */
$username = '[Username]';
$password = '[Password]';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json')
);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
$errors = curl_error($ch);
$result = curl_exec($ch);
//$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
//echo $returnCode;
//var_dump($errors);
$json = json_decode($result, true);
foreach($json['pridexElement']['legalEntity'] as $item) {
$legalentityid = $item['legalEntityIdentifier'];
$legalentityorgname = $item['legalEntityOrganizationName'];
$legalentity[] = array('legalentityid' => ''.$legalentityid,'legalentityorgname' => $legalentityorgname);
}
//print_r($watersys);
echo json_encode($legalentity);
?>