Welcome Guest, Not a member yet? Register   Sign In
How to connect google api (analytics) in my web application
#1

[eluser]Rumel[/eluser]
I am new in google api. i am try to add google api in my web application. but not connect this.

I get the token that given by the google. i have AuthSubSessionToken now i what to do this for google api connection. please anyone help me.
#2

[eluser]boudou[/eluser]
ill post you only the auth function

Code:
/**
* Google Analytics PHP API
*
* This class can be used to retrieve data from the Google Analytics API with PHP
* It fetches data as array for use in applications or scripts
*  
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* Credits: http://www.alexc.me/
* parsing the profile XML to a PHP array
*  
*
* @link http://www.swis.nl
* @copyright 2009 SWIS BV
* @author Vincent Kleijnendorst - SWIS BV (vkleijnendorst [AT] swis [DOT] nl)
*
* @version 0.1
*/

private function auth(){
        
        if (isset($_SESSION['auth'])){
            $this->_sAuth = $_SESSION['auth'];
            return;
        }
        
        $aPost = array ( 'accountType'   => 'GOOGLE',
                         'Email'         => $this->_sUser,
                         'Passwd'        => $this->_sPass,
                         'service'       => 'analytics',
                         'source'        => 'SWIS-Webbeheer-4.0');
      
        $sResponse = $this->getUrl('https://www.google.com/accounts/ClientLogin',$aPost);
    
        $_SESSION['auth'] = '';
        if (strpos($sResponse, "\n") !== false){
            $aResponse = explode("\n", $sResponse);
            foreach ($aResponse as $sResponse){
                if (substr($sResponse, 0, 4) == 'Auth'){
                    $_SESSION['auth'] = trim(substr($sResponse, 5));
                }
            }
        }
        if ($_SESSION['auth'] == ''){
            unset($_SESSION['auth']);
            throw new Exception('Retrieving Auth hash failed!');
        }
        $this->_sAuth = $_SESSION['auth'];
    }

and then

Code:
private function getXml($sUrl){
        
        return $this->getUrl($sUrl, array(), array('Authorization: GoogleLogin auth=' . $this->_sAuth));
    }

hope it helps
#3

[eluser]Rumel[/eluser]
I have token, giving the google. Now i need to use this token established the connection with google for retrieving data in google analytic services.


how to transfer this token in google . please any one help me.




Theme © iAndrew 2016 - Forum software by © MyBB