gapi.client.load 未調用回調:console.log 中指定了無效或非法字符串錯誤 (gapi.client.load not calling callback: An invalid or illegal string was specified error in console.log)


問題描述

gapi.client.load 未調用回調:console.log 中指定了無效或非法字符串錯誤 (gapi.client.load not calling callback: An invalid or illegal string was specified error in console.log)

I have code ‑ unchanged from yesterday ‑ that just stopped working. Odd, I know. But I've looked at it over and over. And nothing in my code has changed.

I am using the Javascript API Client library to load the 'plus' API. As of last night (7/25/2013), this code was working fine. Now, I get the gapi.client and call gapi.client.load and the callback is never getting called.

In my index.html, I have the following:

<script type="text/javascript" src="https://apis.google.com/js/client.js?onload=onLoadCallback"></script>

My onLoadCallback() function looks like this:

function onLoadCallback() {
    try{
        console.log( "gapi.client: " + gapi.client  );
        gapi.client.load('plus', 'v1', function() {
                     console.log('plus loaded!');
                     });
    }
    catch(err) {
        console.log( "onLoadCallback error: " + err.message );
    }
}

This callback never gets called (and I've checked for syntax errors so if there are any above it was during my copy/paste into StackOverflow).

When I load this code in Chrome and look at the console: I see the following:

gapi.client: [object Object] 

followed by:

Uncaught SyntaxError: An invalid or illegal string was specified. 
rs=AItRSTMqSYNvDyDFNs8wjPrZc5pR‑M_27Q:83

And, when clicking on that reference to rs=....:83, it seems to be in the middle of some code that isn't my code. Looks like something to do with the Google API Javascript library.

I should also note that, if I comment out the gapi.client.load line, then this error doesn't appear on the Javascript console. So, it definitely seems to be a result of the call to gapi.client.load.

Has anyone else experienced any unusual behavior or changes to the GAPI Javascript client library that would cause this error?

Thanks for any help or insight.

[NOTE: Tagged as Google‑App‑Engine because this also happens to be in an app accessing an App Engine and asking for the user's ID to access it. And there isn't a StackOverflow tag for Google‑API‑Client‑Library yet.]

[Edit: I should note that the original app is in PhoneGap. The comments on looking in the Javascript console below are from when I was trying to debug the app in a browser since the console logging from the PhoneGap app was less than satisfactory.]


參考解法

方法 1:

Those of us PhoneGap developers who were affected by this are waiting for confirmation that this was confirmed and fixed at the Google API Javascript Client level. However, overnight, the gapi.client.load started working again.

The issue was entered and tracked at: https://code.google.com/p/google‑api‑javascript‑client/issues/detail?id=95

(by JA_251JA_251)

參考文件

  1. gapi.client.load not calling callback: An invalid or illegal string was specified error in console.log (CC BY‑SA 3.0/4.0)

#google-api #javascript #google-api-client #cordova #google-app-engine






相關問題

在 PHP 中壓縮 JSON 字符串並在 Javascript 中解壓縮以進行 Google API 的數據庫查詢 (Compress JSON string in PHP and decompress in Javascript for Database query for Google API)

將 Google Places API 與 MonoTouch 一起使用? (Using Google Places API with MonoTouch?)

如何獲取我的 Gmail 帳戶的個人資料圖片? (How to get the profile picture of my Gmail account?)

google.elements.newsShow 顯示時間不起作用 (google.elements.newsShow display Time not working)

gapi.client.load 未調用回調:console.log 中指定了無效或非法字符串錯誤 (gapi.client.load not calling callback: An invalid or illegal string was specified error in console.log)

Google Developer Console 和已安裝的應用 (Google Developer Console and Installed App)

如何從 Google 自定義搜索 API 獲得 100 多個結果 (How to get more than 100 results from Google Custom Search API)

Pandas / Google Analytics API 身份驗證嘗試給我帶來了一個奇怪的 python 錯誤 (Pandas / Google Analytics API authentication attempt throws me a weird python error)

在 alpha 階段使用谷歌云功能進行生產 (Using a google cloud feature in alpha stage for production)

流量中的 Google Maps Distance Matrix API 持續時間添加返回錯誤結果的所有段 (Google Maps Distance Matrix API duration in traffic adding all segments returning wrong result)

Python 事件集成中的 QML Calendar 和 Google Calendar API (QML Calendar and Google Calendar API in Python events integration)

獲取錯誤 {“error”:“invalid_grant”,“error_description”:“令牌已過期或撤銷。” 來自谷歌 oauth2 API (Getting error { "error" : "invalid_grant", "error_description" : "Token has been expired or revoked." } from Google oauth2 API)







留言討論