I have calculated the distances between cities through the google api service.
I need to get the distances into a distance matrix in R, but when I use the code: 

```
de1 <- "http://maps.googleapis.com/maps/api/distancematrix/json?origins=Berlin|Hamburg|Muenchen|Koeln|Frankfurt am Mein|Duesseldorf|Bremen|Hannover|Nuernberg&destinations=Berlin|Hamburg|Muenchen|Koeln|Frankfurt am Mein|Duesseldorf|Bremen|Hannover|Nuernberg&mode=driving&language=en&sensor=false"
webpage1 <- getURL(de1)
webpage1 <- readLines(tc <- textConnection(webpage1)); close(tc)
pagetree <- htmlTreeParse(webpage1, error=function(...){})

```

If I then type "pagetree" I get an error message. 

```
  > pagetree
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 400 (Bad Request)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}
</style>
<a href="//www.google.com/"><img src="//www.google.com/images/errors/logo_sm.gif" alt="Google"></a>
</head>
<body>
<p><b>400.</b> <ins>That&acirc;&#128;&#153;s an error.</ins>
</p>
<p>Your client has issued a malformed or illegal request.  <ins>That&acirc;&#128;&#153;s all we know.</ins></p>
</body>
</html>

```

Can somebody help me out?

Thank you,
sofia p.