22个稳定版本 (4个主要版本)
5.0.4+20201002 | 2024年3月5日 |
---|---|
3.1.0+20201002 | 2022年4月26日 |
3.0.0+20201002 | 2022年3月8日 |
2.0.4+20201002 | 2021年4月15日 |
0.3.6+20160907 | 2016年9月11日 |
#24 in #api-version
每月下载量 475
1MB
11K SLoC
adsense1d4
命令行界面(CLI)允许您在终端舒适地使用Google AdSense服务的大部分功能。
默认情况下,所有输出都会打印到标准输出,但可以通过标志将其定向到文件,而无需考虑shell的能力。错误将打印到标准错误,并导致程序的退出码非零。
如果请求数据结构,则这些结构将作为格式化的JSON返回,以便作为其他工具的输入。
有关AdSense API的所有其他信息,请参阅官方文档网站。
安装和源代码
使用cargo安装命令行界面:
cargo install google-adsense1d4-cli
在GitHub上找到源代码。
用法
本文档是根据修订版20201002的AdSense API生成的。CLI版本为5.0.4。
adsense1d4 [options]
accounts
adclients-get-ad-code <account-id> <ad-client-id> [-p <v>]... [-o <out>]
adclients-list <account-id> [-p <v>]... [-o <out>]
adunits-customchannels-list <account-id> <ad-client-id> <ad-unit-id> [-p <v>]... [-o <out>]
adunits-get <account-id> <ad-client-id> <ad-unit-id> [-p <v>]... [-o <out>]
adunits-get-ad-code <account-id> <ad-client-id> <ad-unit-id> [-p <v>]... [-o <out>]
adunits-list <account-id> <ad-client-id> [-p <v>]... [-o <out>]
alerts-delete <account-id> <alert-id> [-p <v>]...
alerts-list <account-id> [-p <v>]... [-o <out>]
customchannels-adunits-list <account-id> <ad-client-id> <custom-channel-id> [-p <v>]... [-o <out>]
customchannels-get <account-id> <ad-client-id> <custom-channel-id> [-p <v>]... [-o <out>]
customchannels-list <account-id> <ad-client-id> [-p <v>]... [-o <out>]
get <account-id> [-p <v>]... [-o <out>]
list [-p <v>]... [-o <out>]
payments-list <account-id> [-p <v>]... [-o <out>]
reports-generate <account-id> <start-date> <end-date> [-p <v>]... [-o <out>]
reports-saved-generate <account-id> <saved-report-id> [-p <v>]... [-o <out>]
reports-saved-list <account-id> [-p <v>]... [-o <out>]
savedadstyles-get <account-id> <saved-ad-style-id> [-p <v>]... [-o <out>]
savedadstyles-list <account-id> [-p <v>]... [-o <out>]
urlchannels-list <account-id> <ad-client-id> [-p <v>]... [-o <out>]
adclients
list [-p <v>]... [-o <out>]
adunits
customchannels-list <ad-client-id> <ad-unit-id> [-p <v>]... [-o <out>]
get <ad-client-id> <ad-unit-id> [-p <v>]... [-o <out>]
get-ad-code <ad-client-id> <ad-unit-id> [-p <v>]... [-o <out>]
list <ad-client-id> [-p <v>]... [-o <out>]
alerts
delete <alert-id> [-p <v>]...
list [-p <v>]... [-o <out>]
customchannels
adunits-list <ad-client-id> <custom-channel-id> [-p <v>]... [-o <out>]
get <ad-client-id> <custom-channel-id> [-p <v>]... [-o <out>]
list <ad-client-id> [-p <v>]... [-o <out>]
metadata
dimensions-list [-p <v>]... [-o <out>]
metrics-list [-p <v>]... [-o <out>]
payments
list [-p <v>]... [-o <out>]
reports
generate <start-date> <end-date> [-p <v>]... [-o <out>]
saved-generate <saved-report-id> [-p <v>]... [-o <out>]
saved-list [-p <v>]... [-o <out>]
savedadstyles
get <saved-ad-style-id> [-p <v>]... [-o <out>]
list [-p <v>]... [-o <out>]
urlchannels
list <ad-client-id> [-p <v>]... [-o <out>]
adsense1d4 --help
Configuration:
[--scope <url>]...
Specify the authentication a method should be executed in. Each scope
requires the user to grant this application permission to use it.
If unset, it defaults to the shortest scope url for a particular method.
--config-dir <folder>
A directory into which we will store our persistent data. Defaults to
a user-writable directory that we will create during the first invocation.
[default: ~/.google-service-cli]
配置
程序将所有持久数据存储在~/.google-service-cli
目录中的JSON文件中,文件名以adsense1d4-
开头。您可以使用--config-dir
标志在每次调用中更改用于存储配置的目录。
以下段落提供了有关各种类型持久数据的更多信息。
身份验证
大多数API要求用户对任何请求进行身份验证。如果是这种情况,则作用域确定授予的权限集。这些通常不会超过只读或完全访问。
如果未设置,系统将自动选择最小的可行范围,例如调用只读方法时,它将仅请求只读范围。您可以使用--scope
标志直接指定范围。所有适用的范围均在相应方法的CLI文档中记录。
首次使用范围时,用户将被要求授权。按照CLI给出的说明授权或拒绝。
如果用户已对某个范围进行认证,相关信息将以JSON格式存储在配置目录中,例如:~/.google-service-cli/adsense1d4-token-<scope-hash>.json
。不需要手动管理这些令牌。
要撤销授予的认证,请参阅官方文档。
应用程序密钥
为了允许任何应用程序使用Google服务,它需要使用Google开发者控制台进行注册。然后逐个启用该应用程序可能使用的API。大多数API可以免费使用,并有每日配额。
为了在不强制任何人注册自己的应用程序的情况下更方便地使用CLI,CLI自带了一个相应的默认应用程序密钥。这也意味着全球范围内的重用可能会耗尽每日配额。
您可以通过将您的自己的密钥文件放在此位置来解决这个问题:~/.google-service-cli/adsense1d4-secret.json
,假设已为它启用了所需的adsense API。这样的密钥文件可以在Google开发者控制台的APIs & auth -> Credentials -> Download JSON中下载并直接使用。
有关如何设置Google项目和启用API的更多信息,请参阅官方文档。
调试
尽管CLI尽力提供可用的错误消息,但有时可能需要知道导致特定问题的确切原因。这是通过允许所有客户端服务器通信以原样输出到标准错误来实现的。
--debug
标志将以Debug
表示形式将错误打印到标准错误。
您可以考虑将标准错误重定向到文件以便于使用,例如:adsense1d4 --debug <resource> <method> [options] 2>debug.txt
。
依赖项
~20–31MB
~577K SLoC