【问题标题】:How to update Google Pay For Passes如何更新 Google Pay For Pass
【发布时间】:2020-03-11 00:03:34
【问题描述】:

我想更新 Google Pay for pass 的数据。 在更新之前,我已经使用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}'

但它会返回

<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}

请让我教。

【问题讨论】:

    标签: curl google-pay


    【解决方案1】:

    如果您查看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
    

    请注意,调用有特殊的授权标头,因此仅使用 curl 可能不是最好的,但有一个 [工具] (https://developers.google.com/pay/passes/support/testing) 可以生成授权令牌以使 curl 工作。

    如果你要插入一个类,这个 url 将是 POST https://walletobjects.googleapis.com/walletobjects/v1/offerClass

    如果您要更新课程。应该是PUT https://walletobjects.googleapis.com/walletobjects/v1/offerClass/{resourceId}

    【讨论】:

      猜你喜欢
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2019-06-16
      • 1970-01-01
      • 2018-10-23
      • 1970-01-01
      • 2019-07-11
      • 2020-03-04
      相关资源
      最近更新 更多