php - 使用 OAuth2.0 在 PHP 中包含 Google Sitemap Api
问题描述
在 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);
错误信息:
无法打开流:HTTP 请求失败!HTTP/1.0 401 未经授权
API-key 正确无限制。它绑定到“Google Search Console API”。“Google Search Console API”也被激活。
如何正确授权?
解决方案
至少我找到了一个名为:google-api-php-client 的解决方案,它托管在 GitHub 上:
推荐阅读
- laravel - 服务器上的 Laravel 会话缓存(配置错误)
- java - 为什么即使我使用相同的公式,我的 TI-84 Plus 计算器和 Google 的计算答案也比我的 Java 计算答案略高?
- json - 如何使用键值结构数组解组 JSON,其中键没有 json 标记
- reactjs - 在 React Native 中很难从一个屏幕导航到另一个屏幕
- java - 个人身份证生成器
- javascript - 在 Javascript 中构建相互依赖的功能标志
- amazon-web-services - 当团队成员将 APIG 部署到特定阶段时,使用 SNS 触发 Lambda/通知
- python - 我可以从 Scrapy 中的自定义 Spider 继承吗?
- git - Git stash apply - git 在申请之前会尝试合并吗?
- node.js - NodeJS 需要多个脚本同步执行