Showing posts with label access_token. Show all posts
Showing posts with label access_token. Show all posts

1 March 2013

fetch google contacts using access_token and parse it

<?php
$access_token=$_GET['access_token'];
$max_results=$_GET['max_results'];
$api_url="https://www.google.com/m8/feeds/contacts/default/full";
$emails=array();
$content=file_get_contents("$api_url?access_token=$access_token&max-results=$max_results");

//https://www.google.com/m8/feeds/contacts/default/full?access_token=<your access token>&max-results=<maximum contacts>

$parser = xml_parser_create();
xml_parse_into_struct($parser, $content, $contacts);
xml_parser_free($parser);
foreach($contacts as $contact)
{
if($contact[tag]=="GD:EMAIL")
{
$emails[]=$contact[attributes][ADDRESS];
}
}
print_r($emails);//array of all email address
?>