FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LastCodingProjectOfUniversity/googlemapapi.php at master · Sirbu/LastCodingProjectOfUniversity · GitHub
Sirbu
/
LastCodingProjectOfUniversity
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LastCodingProjectOfUniversity
/
googlemapapi.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (37 loc) · 1.15 KB
Breadcrumbs
LastCodingProjectOfUniversity
/
googlemapapi.php
Copy path
File metadata and controls
45 lines (37 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/bin/php -q
<?php
function
calculDistance
(
$
depart
,
$
destination
) {
$
ch
=
curl_init
();
curl_setopt
(
$
ch
,
CURLOPT_URL
,
"
https://maps.googleapis.com/maps/api/distancematrix/json?origins=
$
depart
&destinations=
$
destination
&key=AIzaSyA5TmSOwCKpxqyYid46sPvhsk0eqtkcOdM
"
);
curl_setopt
(
$
ch
,
CURLOPT_RETURNTRANSFER
,
true
);
//Set CURLOPT_FOLLOWLOCATION to true to follow redirects.
curl_setopt
(
$
ch
,
CURLOPT_FOLLOWLOCATION
,
true
);
//Execute the request.
$
data
=
curl_exec
(
$
ch
);
//Close the cURL handle.
curl_close
(
$
ch
);
#echo $data;
//Print the data out onto the page.
$
rep
=
json_decode
(
$
data
,
true
);
#echo "+++++++++++++\n";
$
elmnt
=
$
rep
[
'
rows
'
][
0
][
'
elements
'
][
0
];
# echo "------------";
# echo $elmnt ['elements']['distance']['text'];
#var_dump ($elmnt);
# echo "------------\n";
#oint_r ($elmnt);
echo
"
la distance:
"
;
#echo $elmnt['distance']['text'];
echo
"\n
la durée:
"
;
#echo $elmnt['duration']['text'];
echo
"\n"
;
if
(!
strcmp
(
$
elmnt
[
'
status
'
],
"
NOT_FOUND
"
)){
return
$
elmnt
[
'
status
'
];
}
else
{
$
tmp
=
explode
(
"
"
,
$
elmnt
[
'
distance
'
][
'
text
'
]);
return
$
tmp
[
0
];
}
}
#$reponse=calculDistance ('Toulouse','Biarritz');
#echo "This is the response : " . $reponse;
?>
Back
|
FazBrowse Home
|
New Git URL