php - Editing google contacts and adding new google contacts through codeigniter application -


good afternoon, have created page can import google contacts , display them using oauth2. have used google-api-php-client this. can contacts' details , display them. however, main goal able edit google contacts' details , add new google contacts codeigniter application based on particular user actions. want know functions need write , in corresponding views. please me. thank in advance.

code:

<?php  error_reporting(e_all); ini_set("display_errors", 1);  session_start(); ?> <!doctype html> <html class="no-js" lang="en"/> <head>     <meta charset="utf-8" />     <meta name="viewport" content="width=device-width" />     <title>google contacts api</title> </head>  <body> <h2>google contacts api v3.0</h2> <?php require_once 'lib/google-api-client/autoload.php'; require 'lib/google-api-client/config.php'; require 'lib/google-api-client/google_client.php';  $client_id = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbb.cccccccccccc.com'; $client_secret = 'e3fsfds4gfg23ha93kmkfkfgk'; $redirect_uri = 'http://ccccccccccccccccccc.com/rddddddddddd/index.php';  $client = new google_client(); $client -> setapplicationname('contact'); $client -> setclientid($client_id); $client -> setclientsecret($client_secret); $client -> setscopes('https://www.google.com/m8/feeds'); $client -> setredirecturi($redirect_uri); $client -> setaccesstype('online');  if (isset($_get['code'])) {     $client->authenticate($_get['code']);     $_session['token'] = $client->getaccesstoken();     header('location: ' . $redirect_uri); }  if(!isset($_session['token'])) {     $url = $client->createauthurl($_session['token']);     echo '<a href="' . $url . '">import google contacts</a>'; }else{         $client->setaccesstoken($_session['token']);         $token = json_decode($_session['token']);         $token->access_token;         $curl = curl_init("https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=1000&access_token=" . $token->access_token);         curl_setopt($curl, curlopt_returntransfer, true);         curl_setopt($curl, curlopt_ssl_verifypeer, false);         curl_setopt($curl, curlopt_timeout, 10);         $contacts_json = curl_exec($curl);         curl_close($curl);         $contacts = json_decode($contacts_json, true);         $return = array();         foreach($contacts['feed']['entry'] $contact){             $return[] = array(             'name' => $contact['title']['$t'],             'email' => isset($contact['gd$email'][0]['address']) ? $contact['gd$email'][0]['address'] : false,             'phone' => isset($contact['gd$phonenumber'][0]['$t']) ? $contact['gd$phonenumber'][0]['$t'] :false,             );         }         echo "<pre>";         var_dump($return);         echo "</pre>";     }        ?>  </body> </html> 

please feel free ask more details.

to update contact, first retrieve contact entry (which have done), modify data , send authorized put request contact's edit url modified contact entry in body.

url: https://www.google.com/m8/feeds/contacts/useremail/full/{contactid}

to create new contact, send authorized post request user's contacts feed url contact data in body.

url: https://www.google.com/m8/feeds/contacts/{useremail}/full


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -