Google Analytics PHP API重定向URI [英] Google Analytics PHP API Redirect URI

查看:109
本文介绍了Google Analytics PHP API重定向URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的本地计算机上测试Google Analytics(分析)API(使用oauth 2.0),我想知道是否有可能以这种方式工作,因为他们要求我在Google API控制台中插入重定向URI,然后在我的代码中输入它,但我不知道此重定向URI应该是什么?

I'm testing the Google Analytics API (with oauth 2.0) on my local machine and I want to know if it's possible to get it to work this way as they request me to insert a Redirect URI in the Google APIs Console and then enter it in my code but I do not know what this Redirect URI should be?

我当前的重定向URI是https://localhost/oauth2callback,我尝试了https://gapi.local/oauth2callback,但均不适合我.

My current Redirect URI is https://localhost/oauth2callback and I tried https://gapi.local/oauth2callback but neither works for me.

我收到此错误消息:
Fatal error: Call to undefined method apiClient::setClientRedirectUri() in C:\xampp\htdocs\webs\gapi\HelloAnalyticsApi.php on line 15

任何帮助将不胜感激.

推荐答案

google-api-php-client库apiClient中没有方法setClientRedirectUri().正确的方法称为 setRedirectUri() :

The google-api-php-client library has no method setClientRedirectUri() in apiClient. The correct method is called setRedirectUri():

$client = new apiClient();
$client->setApplicationName('Hello Analytics API Sample');

// Visit //code.google.com/apis/console?api=analytics to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId('insert_your_oauth2_client_id');
$client->setClientSecret('insert_your_oauth2_client_secret');
$client->setRedirectUri('insert_your_oauth2_redirect_uri');
$client->setDeveloperKey('insert_your_developer_key');
$client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));

这篇关于Google Analytics PHP API重定向URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆