Beispiel #1
0
function getGoogleConnectLink($consumer_key, $consumer_secret, $callback)
{
    $argarray = array();
    $oauth = new GmailOath($consumer_key, $consumer_secret, $argarray, FALSE, $callback);
    $getcontact = new GmailGetContacts();
    $access_token = $getcontact->get_request_token($oauth, false, true, true);
    $_SESSION['oauth_token'] = $access_token['oauth_token'];
    $_SESSION['oauth_token_secret'] = $access_token['oauth_token_secret'];
    return $link = '<a href="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=' . $oauth->rfc3986_decode($access_token["oauth_token"]) . '"> connect </a>';
}
Beispiel #2
0
<?php

include_once 'GmailOath.php';
include_once 'Config.php';
session_start();
$oauth = new GmailOath($consumer_key, $consumer_secret, $argarray, $debug, $callback);
$getcontact = new GmailGetContacts();
$access_token = $getcontact->get_request_token($oauth, false, true, true);
$_SESSION['oauth_token'] = $access_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $access_token['oauth_token_secret'];
$a = $access_token['oauth_token'];
?>

<a href="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=<?php 
echo $oauth->rfc3986_decode($a);
?>
"> <img src='Googleconnect.png' alt="Google Oauth Connect" border='0'/> </a>

 public function find_friends_gmail_old()
 {
     $returnStr['status_code'] = 1;
     error_reporting(0);
     include_once './invite_friends/GmailOath.php';
     include_once './invite_friends/Config.php';
     $oauth = new GmailOath($consumer_key, $consumer_secret, $argarray, $debug, $callback);
     $getcontact = new GmailGetContacts();
     $access_token = $getcontact->get_request_token($oauth, false, true, true);
     $this->session->set_userdata('oauth_token', $access_token['oauth_token']);
     $this->session->set_userdata('oauth_token_secret', $access_token['oauth_token_secret']);
     $returnStr['url'] = "https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=" . $oauth->rfc3986_decode($access_token['oauth_token']);
     $returnStr['message'] = '';
     echo json_encode($returnStr);
 }
    $oAccessToken = $oGetContacts->get_access_token($oAuth, $sDecodedToken, $sDecodedTokenSecret, $oAuthVerifier, false, true, true);
    $sAccessToken = $oAuth->rfc3986_decode($oAccessToken['oauth_token']);
    $sAccessTokenSecret = $oAuth->rfc3986_decode($oAccessToken['oauth_token_secret']);
    $aContacts = $oGetContacts->GetContacts($oAuth, $sAccessToken, $sAccessTokenSecret, false, true, $iMaxResults);
    // turn array with contacts into html string
    $sContacts = $sContactName = '';
    foreach ($aContacts as $k => $aInfo) {
        $sContactName = end($aInfo['title']);
        $aLast = end($aContacts[$k]);
        foreach ($aLast as $aEmail) {
            $sContacts .= '<p>' . $sContactName . '(' . $aEmail['address'] . ')</p>';
        }
    }
} else {
    // prepare access token and set it into session
    $oRequestToken = $oGetContacts->get_request_token($oAuth, false, true, true);
    $_SESSION['oauth_token'] = $oRequestToken['oauth_token'];
    $_SESSION['oauth_token_secret'] = $oRequestToken['oauth_token_secret'];
}
?>
<!DOCTYPE html>
<html lang="en" >
    <head>
        <meta charset="utf-8" />
        <title>Google API - Get contact list | Script Tutorials</title>
        <link href="css/main.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <header>
            <h2>Google API - Get contact list</h2>
            <a href="http://www.script-tutorials.com/google-api-get-contact-list/" class="stuts">Back to original tutorial on <span>Script Tutorials</span></a>