【问题标题】:Google Play Developer API: What is Edit Identifier for an APK and (how) can I find it programaticallyGoogle Play Developer API:什么是 APK 的编辑标识符以及(如何)以编程方式找到它
【发布时间】:2020-06-27 15:04:33
【问题描述】:
我正在尝试使用 GP Developer API(没有太多成功)并继续返回 editID 问题。比如在the reference page for Edits.apks:list,我们看到一个HTTP请求的例子:
GET https://www.googleapis.com/androidpublisher/v3/applications/packageName/edits/editId/apks
那里的editId是什么?对于已经上传到 GP 控制台的 APK,我在哪里可以找到它?更好的是,我可以使用 API 本身找到它吗?
【问题讨论】:
标签:
google-play-developer-api
【解决方案1】:
如果有人像我一样对 GP 文档感到困惑:
GP Developer API docs for Edits(恭喜你,如果你只是想获取一些信息,你应该在名为“Edits”的页面上)咕哝着关于“调用 Edits:插入并指定要修改的应用程序” 。”我不想以任何方式插入任何内容或修改任何内容,但是可以。然后“您可以通过调用适当的方法来进行更改 [...] 并传递应用程序的 ID 并编辑您想要修改的内容。”哪个编辑 ID?
长话短说,看起来 GP 希望您为您将与他们的服务器进行的每个交换会话请求一个标记,然后用该标记标记所有交互。获得标记的方法是使用您的 apk 名称调用 insert 函数,并且没有其他参数(duh)。
所以在 python 中它应该看起来像这样:
from googleapiclient import discovery
from google.oauth2 import service_account
package_name = "com.pkg.name"
scopes = ['https://www.googleapis.com/auth/androidpublisher']
sa_file = "your_key.json"
credentials = service_account.Credentials.from_service_account_file(sa_file, scopes=scopes)
# see the list of discoverable api's here https://www.googleapis.com/discovery/v1/apis
service = discovery.build('androidpublisher', 'v3', credentials=credentials)
# note that insert() returns a request that needs to be exexuted
request = service.edits().insert(packageName=package_name)
response = request.execute()
editId = response['id']
# say you want to know the details about your package
request = service.edits().details().get(packageName=package_name, editId=editId)
response = request.execute()
print(response)
那里。