@@ 29-49 (lines=21) @@ | ||
26 | } |
|
27 | ||
28 | ||
29 | public function bulkLookup($postcodes) |
|
30 | { |
|
31 | $data_string = json_encode(array('postcodes' => $postcodes)); |
|
32 | $ch = curl_init('https://api.postcodes.io/postcodes'); |
|
33 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
34 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
|
35 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
36 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
37 | 'Content-Type: application/json', |
|
38 | 'Content-Length: ' . strlen($data_string))); |
|
39 | ||
40 | $result = curl_exec($ch); |
|
41 | curl_close($ch); |
|
42 | $decoded = json_decode($result); |
|
43 | if ($decoded->status == 200) { |
|
44 | return $decoded->result; |
|
45 | } else { |
|
46 | return false; |
|
47 | } |
|
48 | return false; |
|
49 | } |
|
50 | public function nearestPostcodesFromLongLat($longitude, $latitude) |
|
51 | { |
|
52 | $jsonurl = "https://api.postcodes.io/postcodes?lon=".$longitude."&lat=".$latitude; |
|
@@ 63-84 (lines=22) @@ | ||
60 | } |
|
61 | return false; |
|
62 | } |
|
63 | public function bulkReverseGeocoding($geolocations) |
|
64 | { |
|
65 | $data_string = json_encode(array('geolocations' => $geolocations)); |
|
66 | ||
67 | $ch = curl_init('https://api.postcodes.io/postcodes'); |
|
68 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
69 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
|
70 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
71 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
72 | 'Content-Type: application/json', |
|
73 | 'Content-Length: ' . strlen($data_string))); |
|
74 | ||
75 | $result = curl_exec($ch); |
|
76 | curl_close($ch); |
|
77 | $decoded = json_decode($result); |
|
78 | if ($decoded->status == 200) { |
|
79 | return $decoded->result; |
|
80 | } else { |
|
81 | return false; |
|
82 | } |
|
83 | return false; |
|
84 | } |
|
85 | ||
86 | ||
87 | /** |