当前位置: 首页>>代码示例>>PHP>>正文


PHP Social::includeGoogleLib方法代码示例

本文整理汇总了PHP中Social::includeGoogleLib方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::includeGoogleLib方法的具体用法?PHP Social::includeGoogleLib怎么用?PHP Social::includeGoogleLib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Social的用法示例。


在下文中一共展示了Social::includeGoogleLib方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: die

if (!defined('IN_FORMA')) {
    die('You can\'t access!');
}
/* ======================================================================== \
|   FORMA - The E-Learning Suite                                            |
|                                                                           |
|   Copyright (c) 2013 (Forma)                                              |
|   http://www.formalms.org                                                 |
|   License  http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt           |
|                                                                           |
\ ======================================================================== */
use OAuth\OAuth2\Service\Google;
use OAuth\Common\Storage\Session;
use OAuth\Common\Consumer\Credentials;
$social = new Social();
$social->includeGoogleLib();
$client_id = Get::sett('social_google_client_id');
$client_secret = Get::sett('social_google_secret');
//$redirect_uri = Get::sett('url').'index.php?modname=login&op=google_login';
$protocol = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' or isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' or isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) == 'on') ? 'https' : 'http';
$redirect_uri = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?modname=login&op=google_login';
try {
    $serviceFactory = new \OAuth\ServiceFactory();
    $storage = new Session();
    $credentials = new Credentials($client_id, $client_secret, $redirect_uri);
    $googleService = $serviceFactory->createService('google', $credentials, $storage, array('userinfo_email'));
    //, 'userinfo_profile'
    // google login
    // 1. no params $_REQUEST or $_REQUEST['connect'] -> GOTO URL AUTH OR CONNECT GOOGLE ACCOUNT
    // 2. $_REQUEST['code'] -> RETURN OK FROM GOOGLE AUTH
    // 3. $_REQUEST['error'] -> RETURN CANCEL FROM GOOGLE AUTH
开发者ID:abhinay100,项目名称:forma_app,代码行数:31,代码来源:login.google.oauth2.php


注:本文中的Social::includeGoogleLib方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。