NikosTsolakos / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

Contacts api demo #78

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
it is great to see that more and more samples are comming up, but i realy want 
to see samples for the google contacts api. 

Please :-)

most of the php contacts api source seems to be outdated.

Original issue reported on code.google.com by stefan.k...@gmx.net on 27 Jan 2012 at 2:13

GoogleCodeExporter commented 8 years ago
Hey Stefan,

Which apis are you looking to use from the contacts API?  The GData Contacts 
API isn't officially supported by this client library, but it is still possible.

Here's some sample code for getting a list of contacts:
require_once '../../src/apiClient.php';
session_start();

$client = new apiClient();
$client->setApplicationName('Google Contacts PHP Sample');
// Visit https://code.google.com/apis/console?api=contacts to generate your
// oauth2_client_id, oauth2_client_secret, and register your 
oauth2_redirect_uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');

if (isset($_GET['code'])) {
  $client->authenticate();
  $_SESSION['token'] = $client->getAccessToken();
  $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}

if (isset($_SESSION['token'])) {
 $client->setAccessToken($_SESSION['token']);
}

if (isset($_REQUEST['logout'])) {
  unset($_SESSION['token']);
  $client->revokeToken();
}

if ($client->getAccessToken()) {
  $client->setScopes("http://www.google.com/m8/feeds/");
  $req = new apiHttpRequest("https://www.google.com/m8/feeds/contacts/default/full");
  $val = $client->getIo()->authenticatedRequest($req);
  print "<pre>" . print_r($val, true) . "</pre>";

  // The access token may have been updated lazily.
  $_SESSION['token'] = $client->getAccessToken();
} else {
  $auth = $client->createAuthUrl();
}

if (isset($auth)) {
    print "<a class=login href='$auth'>Connect Me!</a>";
  } else {
    print "<a class=logout href='?logout'>Logout</a>";
}
?>

Original comment by chirags@google.com on 9 Feb 2012 at 6:18

GoogleCodeExporter commented 8 years ago
Commit r371: Add an (unsupported) sample application for the Google Contacts 
API.
http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/cont
acts/simple.php

Original comment by chirags@google.com on 22 Feb 2012 at 3:29

GoogleCodeExporter commented 8 years ago
Thanks a lot,

but why has the contacts api only a secondary role? is the a product google 
wants to stop? it is part of the gmail client and i would think because of that 
the contacts api should have a higher priority.

thanks
stefan

Original comment by stefan.k...@gmx.net on 23 Feb 2012 at 8:10

GoogleCodeExporter commented 8 years ago
Why is this contacts addition to the library "unsupported"? I have the example 
working, but I have no further details/instructions for getting the individual 
contacts and of ourse modifying existing and adding new ones. Thanks Chirags 
for adding this as a start though!

Original comment by mcha...@sprugo.com on 2 Mar 2012 at 1:35

GoogleCodeExporter commented 8 years ago
Same question.

Original comment by baptist...@gmail.com on 27 Mar 2012 at 1:21

GoogleCodeExporter commented 8 years ago
Is anyone working on a contacts api wrapper for contacts?  I would be willing 
to invest some time in helping develop such a module.  I have looked over the 
PHP 'google-api-php-client' and it looks like one would add a file to the 
src/contrib/
folder for 
apiContacts.php

Has someone built the bones of such a file?  I would be happy to help get it 
complete.

thanks,

Scott.

Original comment by sc...@realorganized.com on 2 May 2012 at 8:41

GoogleCodeExporter commented 8 years ago
the code specified by chirags is not printing the contacts, can anyone help me 
out on this.

Original comment by blaazet...@gmail.com on 30 May 2012 at 9:20

GoogleCodeExporter commented 8 years ago
Hi,

   May i know how to get gmail contacts details like name,photo etc. in authorized user if it's possible means please provide the code. help me thanks.

Original comment by brindhah...@gmail.com on 18 Aug 2012 at 7:48

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
hello,

I am new for the Google contact API. I wants listing the google contacts and 
can works with an individual contact like modifying, delete and add new one.  
But I found there is File of contact exists in src/contrib of google-api-client 
library. If any other way by which I can do the above mention functionality. 
Thanks in advance.

Regards
singh yogendra

Original comment by yogendra...@daffodilsw.com on 6 Sep 2012 at 5:18

GoogleCodeExporter commented 8 years ago
Could anyone tell me how to fetch phone number? I'm very tired of looking for 
it. I spent lot of time try to do it. Pls give me an example.

Original comment by dobrowol...@gmail.com on 13 Nov 2013 at 11:50

GoogleCodeExporter commented 8 years ago
Here is an example of adding a contact:
http://viawave.ca/welcome/google-apps-api-v3-fetching-contacts-and-adding-contac
ts/

Original comment by marlou...@gmail.com on 2 Apr 2014 at 4:11