如何更新 Google 支付通行证
How to update Google Pay For Passes
我想更新 Google 支付通行证的数据。
在更新之前,我已经使用 sample code provided by Google. 上传了样本通行证
现在,我正在尝试 https://developers.google.com/pay/passes/rest。
但是,我不知道如何在 Mac 终端上使用命令 PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}
更新编辑后的代码。
我尝试发送以下命令。
curl https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID} -XPOST
curl -X PUT 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID}'
但是 returns
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
请教我
如果您查看 rest methods,您将了解如何使用 python:
进行调用
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
}
credentials = makeOauthCredential()
response = None
# Define insert() REST call of target vertical
uri = 'https://walletobjects.googleapis.com/walletobjects/v1'
postfix = 'Class'
path = createPath(verticalType, postfix)
# There is no Google API for Passes Client Library for Python.
# Authorize a http client with credential generated from Google API client library.
## see https://google-auth.readthedocs.io/en/latest/user-guide.html#making-authenticated-requests
authed_session = AuthorizedSession(credentials)
# make the POST request to make an insert(); this returns a response object
# other methods require different http methods; for example, get() requires authed_Session.get(...)
# check the reference API to make the right REST call
## https://developers.google.com/pay/passes/reference/v1/
## https://google-auth.readthedocs.io/en/latest/user-guide.html#making-authenticated-requests
response = authed_session.post(
uri+path # REST API endpoint
,headers=headers # Header; optional
,json=payload # non-form-encoded Payload for POST. Check rest API for format based on method.
)
return response
请注意,调用有特殊授权 headers,因此仅使用 curl 可能不是最好的,但有一个 [工具] (https://developers.google.com/pay/passes/support/testing) 可以生成授权令牌curl 上班。
如果您要插入 class,则此 url 将是 POST https://walletobjects.googleapis.com/walletobjects/v1/offerClass
如果您正在更新 class。它将是 PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}
我想更新 Google 支付通行证的数据。
在更新之前,我已经使用 sample code provided by Google. 上传了样本通行证
现在,我正在尝试 https://developers.google.com/pay/passes/rest。
但是,我不知道如何在 Mac 终端上使用命令 PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}
更新编辑后的代码。
我尝试发送以下命令。
curl https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID} -XPOST
curl -X PUT 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resorceID}'
但是 returns
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
请教我
如果您查看 rest methods,您将了解如何使用 python:
进行调用 headers = {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
}
credentials = makeOauthCredential()
response = None
# Define insert() REST call of target vertical
uri = 'https://walletobjects.googleapis.com/walletobjects/v1'
postfix = 'Class'
path = createPath(verticalType, postfix)
# There is no Google API for Passes Client Library for Python.
# Authorize a http client with credential generated from Google API client library.
## see https://google-auth.readthedocs.io/en/latest/user-guide.html#making-authenticated-requests
authed_session = AuthorizedSession(credentials)
# make the POST request to make an insert(); this returns a response object
# other methods require different http methods; for example, get() requires authed_Session.get(...)
# check the reference API to make the right REST call
## https://developers.google.com/pay/passes/reference/v1/
## https://google-auth.readthedocs.io/en/latest/user-guide.html#making-authenticated-requests
response = authed_session.post(
uri+path # REST API endpoint
,headers=headers # Header; optional
,json=payload # non-form-encoded Payload for POST. Check rest API for format based on method.
)
return response
请注意,调用有特殊授权 headers,因此仅使用 curl 可能不是最好的,但有一个 [工具] (https://developers.google.com/pay/passes/support/testing) 可以生成授权令牌curl 上班。
如果您要插入 class,则此 url 将是 POST https://walletobjects.googleapis.com/walletobjects/v1/offerClass
如果您正在更新 class。它将是 PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}