标签: google-api

Android Google+登录"发生了内部错误"

我正在编写一个允许用户通过Facebook或Google+登录的应用程序.我所做的是为登录编写一个接口,以便可以使用任何一个.经过几个小时拼凑他们的文档后,Facebook登录就变得很好了.另一方面,Google+让我感到困惑,或者我可能只是盯着它看了太久.我一般可以在SO上找到我的问题的解决方案,但是已经有一天时间寻找答案了.

我逐行实施了Google+平台入门.我运行了我的应用程序,我得到了一个页面,要求我批准我的应用程序访问我的Google+帐户.我单击批准,我的应用程序崩溃.:facepalm:我没有在控制台中添加Google+ API.我已经在使用谷歌地图,所以我跳过了这一部分.

现在发生了什么?我有一个无限循环的连接尝试导致Toasts说"发生内部错误".我不再获得Google+批准屏幕.我尝试过SO 15762904的以下解决方案:

  • 生成一个新的控制台密钥(即使谷歌地图工作正常)
  • 用电子邮件和产品名称填写我的同意屏幕
  • 许多答案涉及从已弃用的PlusClient API中删除.setScopes(),这里不适用
  • Double检查开发者控制台中的SHA指纹是否与用于生成API密钥的SHA指纹相同
  • 在设备上退出Google+

这是主要的活动代码. mSession是我用于登录会话的变量.我现在没有按钮设置,我通常在GUI之前去寻找功能.

private Login mSession;

/**************************************************************************
 * Activity life cycle methods
 **************************************************************************/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Populate the main content
    if (savedInstanceState == null) {
        mSession = new GooglePlusLogin(this);
        mSession.openSession();
    }
}

@Override
protected void onStart() {
    super.onStart();

    // Call login session onStart() method
    mSession.onStart();
}

@Override
protected void onStop() {
    super.onStop();

    // Call login session onStop() method
    mSession.onStop(); …
Run Code Online (Sandbox Code Playgroud)

android google-api google-plus

1
推荐指数
1
解决办法
6220
查看次数

使用PHP的Google Spreadsheets API - 致命错误:未捕获的异常

我正在尝试开始使用Google SpreadSheet API.我知道有很多其他语言,但PHP是唯一一个我模糊不清的语言.我在第一个障碍中不断下降并得到:

Fatal error: Uncaught exception 'Google\Spreadsheet\Exception' in 
/Users/djave/Google Drive/Sites/practise/gdata/lib/Google/Spreadsheet/ServiceRequestFactory.php:48 

Stack trace: #0 /Users/djave/Google Drive/Sites/practise/gdata/lib/Google/Spreadsheet/SpreadsheetService.php(37): 
Google\Spreadsheet\ServiceRequestFactory::getInstance() 
  #1 /Users/djave/Google Drive/Sites/practise/gdata/index.php(32): Google\Spreadsheet\SpreadsheetService->getSpreadsheets() 
  #2 {main} thrown in /Users/djave/Google Drive/Sites/practise/gdata/lib/Google/Spreadsheet/ServiceRequestFactory.php on line 48
Run Code Online (Sandbox Code Playgroud)

怎么回事:

步骤1下载并添加文件夹google-api-php-client

接下来,摆弄代码直到它工作

set_include_path('lib/');

require_once 'lib/Google/Client.php';
require_once 'lib/Google/Service/Books.php';

$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey("-------------------------------------");
$service = new Google_Service_Books($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);

foreach ($results as $item) {
    echo $item['volumeInfo']['title'], "<br /> \n";
}
Run Code Online (Sandbox Code Playgroud)

结果:打印出书籍列表

步骤2下载并安装php-google-spreadsheet-client

首先,我将示例完全复制到我拥有的内容之后,然后包含所有正确的文件,直到找到所有内容:

set_include_path('lib/');

require_once 'lib/Google/Client.php';
require_once 'lib/Google/Service/Books.php'; …
Run Code Online (Sandbox Code Playgroud)

php google-app-engine google-api google-apps

1
推荐指数
1
解决办法
2806
查看次数

使用驱动器API访问Google云端硬盘电子表格

我想制作一个使用Google Drive API的网络应用程序来访问位于其Google云端硬盘上的朋友的电子表格.它将读取/写入工作表,但仅此而且只有该工作表.我只想说,过去两天我一直在阅读Google Drive API的文档,但几乎没有显示它.我无法理解它,无论我读了多少个例子,因为API与示例所示的不匹配.我发现使用OAuth2.0进行身份验证时必须有4-5种不同的方式,但是没有一种方法可以使用我从NuGet包管理器(这是谷歌说要获取最新API)的Drive API.没有任何意义.OAuth2Parameters类不存在,所以我不知道如何使用google给出的示例进行身份验证.类似的方式与其他示例相同,例如谷歌的DrEdit.谁能提供一些见解?电子表格将由我的朋友(我必要时)主持,网络应用程序将由免费服务托管,例如AppHarbor.非常感谢你.

.net c# google-api google-spreadsheet-api google-drive-api

1
推荐指数
1
解决办法
5754
查看次数

Python的QPX Express API

我正在尝试使用来自python的Google的QPX Express API.我在发送请求时遇到了两个问题.起初我试过的是这个:

url = "https://www.googleapis.com/qpxExpress/v1/trips/search?key=MY_KEY_HERE"
values = {"request": {"passengers": {"kind": "qpxexpress#passengerCounts", "adultCount": 1}, "slice": [{"kind": "qpxexpress#sliceInput", "origin": "RDU", "destination": location, "date": dateGo}]}}
data = json.dumps(values)
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})
f = urllib2.urlopen(req)
response = f.read()
f.close()
print(response)
Run Code Online (Sandbox Code Playgroud)

基于以下代码:urllib2和json

当我运行上面的代码时,我收到以下错误消息:

TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
Run Code Online (Sandbox Code Playgroud)

我搜索了一个解决方案并根据以下问题调整了我的代码:TypeError:POST数据应该是字节或可迭代的字节.它不能是str

我将代码更改为:

url = "https://www.googleapis.com/qpxExpress/v1/trips/search?key=AIzaSyCMp2ZnKI3J91sog7a7m7-Hzcn402FyUZo"
values = {"request": {"passengers": {"kind": "qpxexpress#passengerCounts", "adultCount": 1}, "slice": [{"kind": "qpxexpress#sliceInput", "origin": "RDU", "destination": …
Run Code Online (Sandbox Code Playgroud)

python post google-api urllib python-3.x

1
推荐指数
1
解决办法
2091
查看次数

创建Google登录页面以访问服务

我需要构建一个连接到Google日历并获取指定事件集的小型Web应用程序.我已经阅读了文档,我了解到我需要对用户进行身份验证,这是我在Google Developer Console上创建的应用程序.

我正在尝试使用弹出窗口实现身份验证(我正在使用fancybox).这是<div>登录数据的来源:<div id="login-popup" style="display:none"></div>

这是我用来调用auth.php文件的JS代码:

    $.get("/auth.php", function(result) {
            $('#login-popup').append(result);
            $.fancybox({
                href: "#login-popup",
                autoSize: true,
                width: "60%",
                fitToView: true
            });
        });
Run Code Online (Sandbox Code Playgroud)

最后,这是将GET请求发送到Google API的PHP代码:

$ch = curl_init();
if($ch) {
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $query);
    $result = curl_exec($ch);

    curl_close($ch);
}
else {
    throw new RuntimeException("Hiba történt a távoli adatok elérése közben!");
}
echo json_encode($result);
Run Code Online (Sandbox Code Playgroud)

所以这个弹出窗口会在此之后出现,因为它应该是:

在此输入图像描述

但是,在我输入凭据后,它会将我重新搜索到Google的登录网站(https://accounts.google.com/ServiceLoginAuth).

我的问题:

我需要能够从这个弹出窗口中获取数据,以获取我以后可以在Calendar API调用中使用的访问令牌.我需要做些什么来实现这一目标?

javascript php rest oauth google-api

1
推荐指数
1
解决办法
222
查看次数

Google Books API JSON和ISBN/VolumeID

我有3000多本书,有些有ISBN号,有些没有.我试图使用Google API搜索查询从JSON文件中获取他们的缩略图(可能是副标题和作者).

我注意到每个搜索查询都会生成不同的JSON文件 - 这是正常的吗?VolumeID查询似乎返回更详细的JSON?我在下面列出了相关的JSON文件.

Setup = Win7,localhost,apache,php,chrome.

isbn:查询:

https://www.googleapis.com/books/v1/volumes?q=isbn:0716604892

返回以下JSON;

{
 "kind": "books#volumes",
 "totalItems": 1,
 "items": [
  {
   "kind": "books#volume",
   "id": "beSP5CCpiGUC",
   "etag": "cNL3l6PTv24",
   "selfLink": "https://www.googleapis.com/books/v1/volumes/beSP5CCpiGUC",
   "volumeInfo": {
    "title": "The 1989 World Book year book",
    "subtitle": "a review of the events of 1988 ; the annual supplement to the World book encyclopedia",
    "authors": [
     "Robert O. Zeleny"
    ],
    "publishedDate": "1989-02-01",
    "industryIdentifiers": [
     {
      "type": "ISBN_10",
      "identifier": "0716604892"
     },
     {
      "type": "ISBN_13",
      "identifier": "9780716604891"
     }
    ],
    "readingModes": {
     "text": false, …
Run Code Online (Sandbox Code Playgroud)

json google-api google-books

1
推荐指数
1
解决办法
9180
查看次数

Google云端存储上传无法使用C#API

我正在尝试通过C#API将简单图像上传到Google云存储.它似乎成功了,但我的Google云端存储桶中没有任何内容.

我到目前为止的代码:

Google.Apis.Services.BaseClientService.Initializer init = new Google.Apis.Services.BaseClientService.Initializer();
init.ApiKey = "@@myapikey@@";
init.ApplicationName = "@@myapplicationname@@";

Google.Apis.Storage.v1.StorageService ss = new Google.Apis.Storage.v1.StorageService(init);

var fileobj = new Google.Apis.Storage.v1.Data.Object()
{
    Bucket = "images",
                    Name = "some-file-" + new Random().Next(1, 666)
};

Stream stream = null;
stream = new MemoryStream(img);

Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload insmedia;
insmedia = new Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload(ss, fileobj, "images", stream, "image/jpeg");
insmedia.Upload();
response.message = img.Length.ToString();
Run Code Online (Sandbox Code Playgroud)

c# google-api google-cloud-storage google-api-dotnet-client

1
推荐指数
1
解决办法
1934
查看次数

Drive SDK没有列出我的所有文件

我试图列出我的驱动器中的所有文件(大约10),但以下将只列出1(这甚至不是我的真实文件)....

代码:

from httplib2 import Http
from oauth2client.client import SignedJwtAssertionCredentials

client='my_client_id'
client_email = 'my_client_email'
with open("/path/to/file.p12") as f:
    private_key = f.read()

credentials = SignedJwtAssertionCredentials(client_email, private_key, 'https://www.googleapis.com/auth/drive')
http_auth = credentials.authorize(Http())
drive_service = build('drive', 'v2', http=http_auth)
r = drive_service.files().list().execute()
files = r['items']
for f in files:
    print f['id'], f['title']
Run Code Online (Sandbox Code Playgroud)

结果:

"<file_id> How to get started with Drive"
Run Code Online (Sandbox Code Playgroud)

编辑: 这个问题是类似的,但答案是有正确的oauth范围,我在上面.

编辑#2:我认为这可能是一个时间问题所以我给了它几个小时但仍然没有鹅.

编辑#3:如果我尝试从另一个用户复制文件然后列出我的文件,那么我将获得2个文件:"如何开始使用驱动器""我的新文件"所以,这只是列出该应用程序创建的文件?我如何获得其余的文件???

python google-api google-drive-api google-drive-realtime-api

1
推荐指数
1
解决办法
443
查看次数

如何重置Google工作表,以便将表单收集的数据放入第一个免费单元格

嘿伙计这可能是一个愚蠢的问题,但我一直在谷歌搜索如何重置电子表格.我目前遇到这个问题,每次我从电子表格中删除数据,然后让用户通过表单输入一些数据,信息放在最后一个单元格曾经有信息的位置.

例如:http://gyazo.com/72b5e58fc17dae3c76cebcd0d72e30e0

然后当我删除这些数据并让用户再次输入一些信息时,它将在第8行开始发布数据,依此类推.

有没有办法重置这个数据,以便将数据存储在第1行.

google-api google-sheets google-forms

1
推荐指数
1
解决办法
6281
查看次数

DataStore超过配额,同时启用了计费和数据存储API

尝试放入数据时出现以下错误:

抱歉,意外错误:API调用datastore_v3.Put()需要的配额多于可用配额

问题是我没有超额配额,并启用了结算和Google Cloud Datastore API.我究竟做错了什么?

google-api app-engine-ndb google-cloud-datastore

1
推荐指数
1
解决办法
183
查看次数