Fastest Web Hosting

how to update gmail contact by google api in php

0 votes
asked Sep 30, 2016 in PHP by vinod.kumar (520 points)

I am using Google client API for getting gmail contact in php. I have create code for add and delete gmail contact API in php but I could not find any API by which I can update any contact in Gmail using Google contact Apin php.

Please help me regarding this.

I have use below code

require_once 'google-api-php-client-1-master/src/Google/autoload.php'; $client = new Google_Client(); $client -> setApplicationName('Gmail Contact'); $client -> setClientid($google_client_id); $client -> setClientSecret($google_client_secret); $client -> setRedirectUri($google_redirect_uri); $client -> setAccessType('offline'); $client -> setApprovalPrompt('force');
$fname = 'testing fname';
    $lname = 'test lname';
    $uemail = '';  
    $uphone = 98651245; 
    $updateXML = '<?xml version="1.0" encoding="utf-8"?>
        <atom:entry xmlns:atom="" xmlns:gd="">
        <atom:category scheme="" term=""/>
        <gd:fullName>'.$fname.' '.$lname.'</gd:fullName>
        <gd:email rel="" address="'.$uemail.'"/>       

    $headers = array(
        'If-Match: Etag',
        'Gdata-version: 3.0',
        'Content-Type: application/atom+xml',
        'Authorization: OAuth '.$accesstoken

    $contacturl = '{'.$contckey.'}';

    $chupp = curl_init();
    curl_setopt($chupp, CURLOPT_URL, $contacturl );
    curl_setopt($chupp, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($chupp, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($chupp, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($chupp, CURLOPT_POSTFIELDS, $updateXML);
    curl_setopt($chupp, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($chupp, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($chupp, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($chupp, CURLOPT_TIMEOUT, 10);
    curl_setopt($chupp, CURLOPT_FAILONERROR, true);

1 Answer

0 votes
answered Apr 4 by anonymous

Hi vinoth,

Can you please suggest me how to delete the existing google contacts ....

Job Board

TechnicalSharp is a technical community of developers where they are sharing their knowledge and solutions and against it they are getting the score point which help them to make profile strong which is under eyes on MNC's