标签: google-api

Google Calendar API:“后端错误”代码503

当我使用Google日历API创建新的日历时,随机出现 “后端错误”。你知道为什么吗?您是否经历过相同的行为?

第一个要求:

POST https://www.googleapis.com/calendar/v3/calendars授权:Bearer ya29.UQEd-xxx内容类型:application / json; 字符集= utf-8

{“摘要”:“我的新日历名称”}

Google回答(约20秒后):

{“错误”:{“错误”:[{“域”:“全局”,“原因”:“ backendError”,“消息”:“后端错误”}]“代码”:503,“消息”:“后端错误“}}

日历未创建

另一个要求:

POST https://www.googleapis.com/calendar/v3/calendars授权:Bearer ya29.UQEd-yyy内容类型:application / json; 字符集= utf-8

{“摘要”:“我的新日历名称”}

Google回答(约5秒后):200日历已创建

google-calendar-api google-api

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

如何延长Google Plus access_token expire_time?

我已经为PHP编写了自己的Google Plus库,到目前为止,它可以成功运行,但存在一个问题,我无法延长访问令牌的expire_time。我需要将其用于进一步处理,我无法期望用户再次登录以续订它。

我想做的就是获得Google+专页的关注人数。我告诉您这是因为,如果有另一种获取方式,那么我将不需要API。

如果没有,那么看看我到目前为止所得到的:

这是我的登录URL生成器:

    public function generateLoginUrl()
    {
        $arr = array(
            "scope" => "https://www.googleapis.com/auth/plus.".implode(".", Config::$scopes)."",
            "state" => "generate_a_unique_state_value",
            "redirect_uri" => Config::$redirect_uri,
            "response_type" => "code",
            "client_id" => Config::$client_id,
            "access_type" => "offline"
        );

        $oauth_url  = "https://accounts.google.com/o/oauth2/auth?".http_build_query($arr);

        return $oauth_url;
    }
Run Code Online (Sandbox Code Playgroud)

这是访问令牌生成器:

    public function getAccessToken()
    {
        $post = array(
            "code" => $_SESSION["code"],
            "grant_type" => "authorization_code",
            "redirect_uri" => Config::$redirect_uri,
            "client_id" => Config::$client_id,
            "client_secret" => Config::$client_secret
        );

        $result = $this->createRequest("https://accounts.google.com/o/oauth2/token", $post);
        $result = json_decode($result);

        $_SESSION["instagram_token"] = $result->access_token;
        unset($_SESSION["code"]);
    }
Run Code Online (Sandbox Code Playgroud)

我从getAccessToken得到的就是这样的例子:

object(stdClass)[2]
  public 'access_token' => string …
Run Code Online (Sandbox Code Playgroud)

php google-api google-plus google-plus-signin

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

使用Google Drive Android API将数据附加到文件

我正尝试使用https://developers.google.com/drive/android/files#making_modifications中提供的程序将数据附加到Google云端硬盘上的现有文件中

虽然控制正常但没有变化反映在文件中.

    public void addHistoryEntry(final String location) {
            final DriveFile file = Drive.DriveApi.getFile(getClient(), historyFileId);
            file.open(getClient(), DriveFile.MODE_READ_WRITE, null)
                    .setResultCallback(new ResultCallback<DriveContentsResult>() {
                            @Override
                            public void onResult(DriveContentsResult driveContentsResult) {
                                    if (!driveContentsResult.getStatus().isSuccess()) {
                                            L.c("Problem in Writing to file");
                                            return;
                                    }
                                    DriveContents contents = driveContentsResult.getDriveContents();
                                    try {
                                            ParcelFileDescriptor parcelFileDescriptor = contents.getParcelFileDescriptor();
                                            FileInputStream fileInputStream = new FileInputStream(parcelFileDescriptor.getFileDescriptor());
                                            // Read to the end of the file.
                                            fileInputStream.read(new byte[fileInputStream.available()]);

                                            // Append to the file.
                                            FileOutputStream fileOutputStream = new FileOutputStream(parcelFileDescriptor
                                                    .getFileDescriptor());
                                            Writer writer = new OutputStreamWriter(fileOutputStream);
                                            writer.write(location+"\n"); …
Run Code Online (Sandbox Code Playgroud)

android google-api google-drive-android-api

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

Google Places Api出错(.addConnectionCallbacks)

public class Places_DATA extends ActionBarActivity
{
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_places);


    mGoogleApiClient = new GoogleApiClient
            .Builder(this)
            .addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}
Run Code Online (Sandbox Code Playgroud)

问题是我继续使用.addConnectionCallbacks(this)收到错误.该错误表明.ConnectionCallbacks无法添加到类中.我不确定我做错了什么,因为我一直关注谷歌的文档,如下所示:https://developers.google.com/places/android/start

android google-api google-places-api android-studio

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

Google API:配额限制重置时间和时区

是否有人了解以下Google API的配额限制/费率限制重置时间?上面的大多数API都有每日配额,其中提到配额会在第二天重置-如果有人知道的话,我想在其中知道时间和时区。

  • Google地方详情
  • Google地方搜索
  • Google Places文字搜寻
  • Google新闻搜寻
  • Google Analytics(分析)配置文件
  • Google Analytics(分析)数据
  • Google自订搜寻
  • Google+搜索
  • Google+活动
  • Google+个人资料
  • 的YouTube

我已经进行了一些研究,有些API并未发布所有此类信息:Google Maps API for Work提到每日配额会在太平洋时间午夜重置,来源:Google Maps API for Work 另外,在Merchant Circle API中,它将重置时间发布为太平洋标准时间(PST)上午12点,来源:Merchant Circle API

google-api youtube-api rate-limiting

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

从appcelerator调用google云视觉API时,为什么会收到无效的JSON有效负载?

我试图使用Alloy Appcelerator的Google vision API v1

我创建了一个请求HTTPClient并调用API https://vision.googleapis.com/v1/images:annotate?key=MY_APP_KEY

但我得到谷歌的响应文本:

  {
 error = {
     code = 400;
     details = (
                  {
                     "@type" = "type.googleapis.com/google.rpc.BadRequest";
                      fieldViolations = ({
                                        description = "Invalid JSON payload received. Unknown name \"request\": Cannot bind query parameter. Field 'request' could not be found in request message.";
                                        });
                  }
                );
     message = "Invalid JSON payload received. Unknown name \"request\": Cannot bind query parameter. Field 'request' could not be found in request message.";
     status = "INVALID_ARGUMENT";
  };
Run Code Online (Sandbox Code Playgroud)

}

我的代码使用Alloy的HTTP请求

var requests …
Run Code Online (Sandbox Code Playgroud)

google-api appcelerator google-vision appcelerator-titanium

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

Google API - 来自Oauth2的令牌请求返回null令牌

对于凭据,我在https://console.developers.google.com上创建了一个开发人员帐户,我创建了一个项目,然后我从API Manager创建了凭据.我使用"google/apiclient":"1.1.*"包.我认为这是凭证的问题.

    $OAUTH2_CLIENT_ID = 'XXXXX-rvm1l9b1nvht9je1ic0bbe05ab5gvhbg.apps.googleusercontent.com';
    $OAUTH2_CLIENT_SECRET = 'XXXXXXP90L_DLD3Nrc_rT4zGD';

    $client = new Google_Client();
    $client->setClientId($OAUTH2_CLIENT_ID);
    $client->setClientSecret($OAUTH2_CLIENT_SECRET);
    $client->setScopes('https://www.googleapis.com/auth/youtube');
    $redirect = url('/');
    $client->setRedirectUri($redirect);


    $token = $client->getAccessToken();
    dd($token);
Run Code Online (Sandbox Code Playgroud)

php google-api oauth-2.0 laravel google-api-php-client

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

Google OAuth 2.0 SAMEORIGIN错误

这是一个与时间一样古老的问题.但是在使用googles javascript API时如何解决SAMEORIGIN错误?

从他们的例子:

let clientId = 'CLIENT_ID';
let apiKey = 'API_KEY';
let scopes = 'https://www.googleapis.com/auth/youtube.readonly';

gapi.client.setApiKey(apiKey);
setTimeout(() => {
  gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, (authResult) => {
    console.log(authResult);
  });
});
Run Code Online (Sandbox Code Playgroud)

我明白了:

拒绝展示'..".在一个框架中,因为它将'X-Frame-Options'设置为'SAMEORIGIN'.

我将API密钥设置为浏览器密钥.并将客户端ID设置为Web应用程序.

我试图通过localhost测试这可能是一个问题.所以在API Key上我将http:// localhost:8000添加到授权的JavaScript起源 - 这可能没有意义,但我认为值得一试.

API密钥不限于任何域,并且OAuth验证屏幕没有域验证.

我也尝试使用--disable-web-security运行chrome但没有运气.

javascript oauth google-api

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

查询Google Analytcs帐户的所有数据

我正在使用Google AnalyticsAPI来制作Python程序.

目前它能够进行特定的查询,但......

是否可以获取包含Google Analytics帐户中所有数据的大型JSON?

我一直在寻找,我没有找到任何答案.

有人知道它是否可能以及如何?

python google-analytics google-api google-analytics-api

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

C#Google API(SheetsServices)插入新行

我如何在我的谷歌电子表格中插入新行.

使用Google API(SheetsServices).

class GoogleAPI
    {
        // If modifying these scopes, delete your previously saved credentials
        // at ~/.credentials/sheets.googleapis.com-dotnet-quickstart.json
        static string[] Scopes = { SheetsService.Scope.Spreadsheets, "email" };
        static string ApplicationName = "Google Sheets API .NET Quickstart";

        public GoogleAPI()
        {
            UserCredential credential;

            using (var stream =
                new FileStream("Secret.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/Secret.json");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;  
                Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Google …
Run Code Online (Sandbox Code Playgroud)

c# google-api

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