我需要撤销我的应用程序订阅,这样我就可以取消订阅了。这显然不可能仅仅使用谷歌的后端。相反,必须使用google-play-android-developer-API。在
我已经下载了pythonandroid play publisher samples,并让它们正常工作。例如,我可以运行basic_list_apks.py脚本来查看apk的列表。这表明我正确地证明了自己
我扩展了相同的basic_list_apks.py来创建一个最小的subscription_revoker.py脚本(内容如下)。它似乎向谷歌传达了正确的细节。如果我把这三个参数(packageName,productId,或purchaseToken)中的任何一个错误,我会从服务器得到一个适当的错误。e、 g."Subscription not found for this application."或{}等
但是,当一切似乎都是正确的,我得到的只是一个500服务器错误:googleapiclient.errors.HttpError:
或者再写一遍,加上换行符以使其更清晰:
^{pr2}$
(我更改了错误的[括号中的]部分,以保持代码的私密性。)
我在google上到处搜索,似乎还有其他人从google那里得到了500个神秘的错误,但没有解决方案。任何帮助都将不胜感激。在
这是我的剧本。要运行它,请下载示例安装上面提到的samples,并将以下内容放入同一目录中的一个文件中并运行它。谢谢任何人能提供的帮助。在import sys
from apiclient import sample_tools
from oauth2client import client
## the values you'll need to change
package_name = 'com.yourcompany.yourapp'
product_id = 'the subscription SKU'
purchase_token = 'the purchase token'
## ## ## ##
def main(argv):
# Authenticate and construct service.
service, flags = sample_tools.init(
argv,
'androidpublisher',
'v2',
__doc__,
__file__,
parents=[],
scope='https://www.googleapis.com/auth/androidpublisher')
try:
request = service.purchases().subscriptions().revoke(packageName=package_name,
subscriptionId=product_id,
token=purchase_token)
result = request.execute()
print(result)
except client.AccessTokenRefreshError:
print ('The credentials have been revoked or expired, please re-run the '
'application to re-authorize')
if __name__ == '__main__':
main(sys.argv)