实施Google+一次性服务器流程

时间:2014-02-06 18:32:52

标签: php google-plus google-api-php-client

尝试按照此实施Google+一次性服务器流程(混合)的示例时: https://developers.google.com/+/web/signin/server-side-flow

我的索引页面出现以下错误:

PHP注意:未定义的变量:第45行的D:\ home \ site \ wwwroot \ beta \ index.php中的应用程序 PHP致命错误:在第45行的D:\ home \ site \ wwwroot \ beta \ index.php中的非对象上调用成员函数set()

    <?php
  require_once "includes/Google/Google_Client.php";
  require_once "includes/Google/contrib/Google_PlusService.php";

  // Create a state token to prevent request forgery.
  // Store it in the session for later validation.
  $state = md5(rand());
  $app['session']->set('state', $state);
  // Set the client ID, token state, and application name in the HTML while
  // serving it.
  return $app['twig']->render('index.php', array(
      'CLIENT_ID' => "ID HERE",
      'STATE' => $state,
      'APPLICATION_NAME' => "TEST APP"
  ));

?>

我已将CLIENT ID和APP NAME替换为示例,以便在此处发布。

有谁知道可能导致这些错误的原因是什么?感谢

1 个答案:

答案 0 :(得分:0)

这可能有所帮助:https://github.com/googleplus/gplus-verifytoken-php/blob/master/verify.php

$app = new Silex\Application();