Witam,
Mam swoją aplikację do której mogę pobrać link z aplikacji maps google.
if (Intent.ACTION_SEND.equals(action) && type != null) {
handleSendText(intent); // Handle text being sent
} else {
// Handle other intents, such as being started from the home screen
}
void handleSendText(Intent intent) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
// Update UI to reflect text being shared
new URLShort().execute(sharedText);
}
}
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
Otrzymuję taki link:
https://goo.gl/maps/n8HffcEcMeG2
Po przez php otrzymuje taki:
http://maps.google.com/?cid=1267127372396791714&hl=en&gl=gb&shorturl=1
a potrzebuję dostać taki:
https://www.google.com/maps/place/aleja+Ignacego+Daszyńskiego+18,+33-332+Kraków,+Poland/@50.057072,19.9505517,17z/data=!3m1!4b1!4m5!3m4!1s0x47165b3e38f9d40d:0x5789306e893bb4da!8m2!3d50.057072!4d19.9527404?hl=en
Ma ktoś pomysł jak to zrobic.
Poniżej skrypt php do otrzymania dłuższego linku:
<?php
$shortUrl = "https://goo.gl/maps/n8HffcEcMeG2";
$apiKey = 'moj_klucz';
$params = array('shortUrl' => $shortUrl, 'key' => $apiKey);
$final_url = 'https://www.googleapis.com/urlshortener/v1/url?'.http_build_query($params);
$curl = curl_init($final_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
$jsonResult = curl_exec($curl);
curl_close($curl);
$resultArray = json_decode($jsonResult, true);
echo json_encode($resultArray);
?>