I'm trying to retrieve an ID from the Google Contacts API v3. I am able to retrieve an entire url with the id at the end.
http://www.google.com/m8/feeds/contacts/mike%40xxxxxxx.com/base/xxxthisistheidxxxx
So I either have split the url in some way or I need to find a completely different way of retrieving the ID.
if (!empty($contacts['feed']['entry'])) {
foreach($contacts['feed']['entry'] as $contact) {
//retrieve Name and email address
$return[] = array (
'firstname'=> $contact['gd$name']['gd$givenName']['$t'],
'lastname'=> $contact['gd$name']['gd$familyName']['$t'],
'email' => $contact['gd$email'][0]['address'],
'phoneNumber' => $contact['gd$phoneNumber'][0]['$t'],
'city' => $contact['gd$structuredPostalAddress'][0]['gd$city']['$t'],
'street' => $contact['gd$structuredPostalAddress'][0]['gd$street']['$t'],
'country' => $contact['gd$structuredPostalAddress'][0]['gd$country']['$t'],
'birthday' => $contact['gContact$birthday']['when'],
'id' => $contact['id']['$t'],
);
}
}
What you could do is split the url on /
's and than take the last index of the outcome.
Example:
$url = "http://www.google.com/m8/feeds/contacts/mike%40xxxxxxx.com/base/xxxthisistheidxxxx";
$exploded = explode('/', $url);
echo end($exploded); //Echoes the last index.