首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >应用程序引擎上的G+应用程序接口出现“服务器错误”

应用程序引擎上的G+应用程序接口出现“服务器错误”
EN

Stack Overflow用户
提问于 2013-11-03 07:17:23
回答 2查看 191关注 0票数 0

我的应用引擎上的Google+应用程序接口有问题。

我在我自己的主机上测试了我的代码,它工作得很好,我不知道为什么当我在应用程序引擎上部署我的代码时,它会给我一个服务器错误。

首先,这里是包含名为(index.php)的文件的G+代码:

代码语言:javascript
复制
<?php


require_once 'Google_Client.php';
require_once 'Google_PlusService.php';
session_start();

$client = new Google_Client();
$client->setApplicationName("Google+ PHP Starter Application");

//Visit https://code.google.com/apis/console?api=plus to generate your
//client id, client secret, and to register your redirect uri.
$client->setClientId('55845591562.apps.googleusercontent.com');
$client->setClientSecret('J-l4j5yxhVsCfrfRHVy1x8IF');
$client->setRedirectUri('http://fictionteam.com/fb/');
$client->setDeveloperKey('AIzaSyCNDNQn7A9M2COPaW1NOYpZEoaiXCNibZ4');
$plus = new Google_PlusService($client);

if (isset($_GET['logout'])) {
  unset($_SESSION['token']);
}

if (isset($_GET['code'])) {
  if (strval($_SESSION['state']) !== strval($_GET['state'])) {
    die("The session state did not match.");
  }
  $client->authenticate();
  $_SESSION['token'] = $client->getAccessToken();
  $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}

if (isset($_SESSION['token'])) {
  $client->setAccessToken($_SESSION['token']);
}

if ($client->getAccessToken()) {
  $me = $plus->people->get('me');
  print "Your Profile: <pre>" . print_r($me, true) . "</pre>";

  $params = array('maxResults' => 100);
  $activities = $plus->activities->listActivities('me', 'public', $params);
  print "Your Activities: <pre>" . print_r($activities, true) . "</pre>";

  $params = array(
    'orderBy' => 'best',
    'maxResults' => '20',
  );
  $results = $plus->activities->search('Google+ API', $params);
  foreach($results['items'] as $result) {
    print "Search Result: <pre>{$result['object']['content']}</pre>\n";
  }

  // The access token may have been updated lazily.
  $_SESSION['token'] = $client->getAccessToken();
} else {
  $state = mt_rand();
  $client->setState($state);
  $_SESSION['state'] = $state;

  $authUrl = $client->createAuthUrl();
  print "<a class='login' href='$authUrl'>Connect Me!</a>";
}

下面是app.yaml的配置:

代码语言:javascript
复制
application: gcdc2013-troubles
version: 1
runtime: php
api_version: 1

handlers:
- url: /
  script: index.php

我把所有的API库都放在应用引擎文件的同一目录下,但是当我访问我的应用引擎链接时,它会提示我"Server Error“

gcdc2013-troubles.appspot.com

EN

回答 2

Stack Overflow用户

发布于 2013-11-03 18:11:22

按照说明设置Google API客户端here

票数 1
EN

Stack Overflow用户

发布于 2013-11-03 17:29:21

您是否在php.ini中包含/取消注释了extension=php_curl.dll

此外,在GAE上,urlfetch似乎比cURL更受欢迎。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19748017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档