【问题标题】:Writing HTTP Headers in XML用 XML 编写 HTTP 标头
【发布时间】:2014-06-16 11:50:40
【问题描述】:

我必须将此 HTTP 请求编码到 XML 中的 Yelp API

    GET /v2/business/yelp-san-francisco HTTP/1.1
Host: api.yelp.com
Authorization: OAuth realm="",oauth_consumer_key="xxxxxxxxxxxxxxxx",oauth_token="xxxxxxxxxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1402918725",oauth_nonce="vCTAQl",oauth_version="1.0",oauth_signature="xxxxxxxxxxxxxxxx"
Cache-Control: no-cache
Postman-Token: 338ad760-49be-df0b-a4ba-3eaa12586cd1

如何在 XML 中实现它?我试过这样:

<property name="yelp.apiUri" value="http://api.yelp.com/v2/" />
    <property name="yelp.oauth.consumerKey" expression="$func:consumerKey" />
    <property name="yelp.oauth.consumerKeySecret" expression="$func:consumerKeySecret" />
    <property name="yelp.oauth.accessToken" expression="$func:accessToken" />
    <property name="yelp.oauth.accessTokenSecret" expression="$func:accessTokenSecret" />

    <property name="yelp.oauth.nonce" value="dummynonce"/>
    <property name="yelp.oauth.timestamp" value="dummytimestamp"/>

    <property name="Authentication" expression="fn:concat(
    'OAuth realm=',
    'oauth_consumer_key=', get-property('yelp.oauth.consumerKey'),
    'oauth_token=', get-property('yelp.oauth.accessToken'),
    'oauth_signature_method=HMAC-SHA1',
    'oauth_timestamp=', get-property('yelp.oauth.timestamp'),
    'oauth_nonce=', get-property('yelp.oauth.nonce'),
    'oauth_version=1.0',
    'oauth_signature=', get-property('yelp.oauth.accessTokenSecret')
    )"/>

但它没有用。

【问题讨论】:

  • 您的配置文件显示为Authentication,但您的标头应为Authorization。它对 Yelp 有影响吗?
  • @helderdarocha,即使我更改了编码,我也无法发送请求
  • 实际上,这是一个猜测。我对yelp一无所知。这不是您在文档中很容易找到的东西吗?他们必须有一些配置示例。

标签: xml rest oauth http-headers yelp


【解决方案1】:

您的标头标签出错。将属性标签替换为标头标签并更改您的代码,如下所示:

    <header name="Authorization" expression="fn:concat(
    'OAuth realm=&quot;&quot;',
    ',oauth_consumer_key=&quot;',get-property('yelp.oauth.consumerKey'),'&quot;',
    ',oauth_token=&quot;',get-property('yelp.oauth.accessToken'),'&quot;',
    ',oauth_signature_method=&quot;HMAC-SHA1&quot;',
    ',oauth_timestamp=&quot;',get-property('yelp.oauth.timestamp'),'&quot;',
    ',oauth_nonce=&quot;',get-property('yelp.oauth.nonce'),'&quot;',
    ',oauth_version=&quot;1.0&quot;',
    ',oauth_signature=&quot;', get-property('yelp.oauth.signature'),'&quot;'
    )" scope="transport" />

【讨论】:

    猜你喜欢
    • 2010-10-13
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    • 2012-12-17
    • 2013-05-07
    • 2013-09-20
    • 1970-01-01
    • 2014-11-05
    相关资源
    最近更新 更多