简体   繁体   English

使用 OAuth2.0 在 PHP 中包含 Google Sitemap Api

[英]Including Google Sitemap Api in PHP with OAuth2.0

While integrating Google Sitemap API in PHP I am logged in with Google OAuth2.0 (works like charm), but this code does not fit :在 PHP 中集成 Google Sitemap API 时,我使用 Google OAuth2.0 登录(就像魅力一样),但这段代码不适合:

$key = 'SOME-GOOGLE-KEY';
$obj = json_decode(file_get_contents("https://www.googleapis.com/webmasters/v3/sites?key=$key"), true);

print_r($obj);

Error-message:错误信息:

failed to open stream: HTTP request failed!无法打开流:HTTP 请求失败! HTTP/1.0 401 Unauthorized HTTP/1.0 401 未经授权

The API-key is correct and has no restrictions. API 密钥是正确的,没有任何限制。 It's bound to "Google Search Console API".它绑定到“Google Search Console API”。 The "Google Search Console API" is activated also. “Google Search Console API”也被激活。

How to authorize correctly?如何正确授权?

At least i found a solution called: google-api-php-client which is hosted at GitHub:至少我找到了一个名为:google-api-php-client 的解决方案,它托管在 GitHub 上:

https://github.com/googleapis/google-api-php-client https://github.com/googleapis/google-api-php-client

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 (PHP)Oauth2.0-错误401 Google通讯录API - (PHP) Oauth2.0 - Error 401 Google Contacts API PHP Adob​​eSign API ::具有OAuth2.0的transientDocuments - PHP AdobeSign API :: transientDocuments with OAuth2.0 带有 PHP API oauth2.0 的 Google 日历服务帐户 - 如何访问未共享的日历 - Google Calendar Service Account with PHP API oauth2.0 - How to access calendars that are not shared Google API OAuth2.0错误请求invalid_grant - Google API OAuth2.0 bad request invalid_grant Google App Engine PHP是否需要OAuth2.0? - Do I need OAuth2.0 for Google App Engine PHP? 如何在PHP中使用Google Oauth2.0打印UserInfo - How to print UserInfo with google Oauth2.0 in Php Twinfield API OAuth2.0 getaccessToken php-twinfield/twinfield - Twinfield API OAuth2.0 getaccessToken php-twinfield/twinfield 使用Oauth2.0身份验证和适用于PHP的Google Contact API时出现“致命错误:未找到类'Google_Http_Request' - “Fatal error: Class 'Google_Http_Request' not found in” while using Oauth2.0 authentication and Google Contact API for PHP 正确设置服务帐户的 OAuth2.0 以使用 Google Ads Api? - Correct OAuth2.0 setup for Service Account to use Google Ads Api? Google OAuth2.0 php客户端使用刷新令牌交换访问令牌 - Google OAuth2.0 php client exchange access token with refresh token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM