0

有人用过freelancer.com api吗?我什至无法检索它的 requestToken。我想要它的Android。我尝试使用路标库,但它给出了以下错误

oauth.signpost.exception.OAuthNotAuthorizedException:授权失败(服务器回复 401)。如果使用者密钥不正确或签名不匹配,则可能会发生这种情况。

我正在使用正确的消费者密钥。同样的方法也适用于 twitter。

4

2 回答 2

0

Earlier versions of signpost only implement OAuth Parameters in the header. The freelanecer.com api expects the parameters to be in the query string. The latest version of Signpost can now implement OAuth parameters in the query string.

Here is the relevant code from the service builder:

  /**
  * Configures the signature type, choose between header, querystring, etc. Defaults to Header
  *
  * @param scope The OAuth scope
  * @return the {@link ServiceBuilder} instance for method chaining
  */
  public ServiceBuilder signatureType(SignatureType type)
  {
     Preconditions.checkNotNull(type, "Signature type can't be null");
     this.signatureType = type;
    return this;
  }

  Service = new ServiceBuilder()
                    .provider(FreelancerApi.class)
                    .apiKey(consumer)
                    .apiSecret(secret)
                    .callback("oob")
                    .signatureType(SignatureType.QueryString)
                    .build();
于 2011-06-08T17:32:11.803 回答
0

回复晚了,但你让它工作了吗?那么,它适用于 Twitter,但不适用于 Freelancer?我在 freelancer 中发现的一件事是,如果 OAuth 参数在标头中发送,它不会采用 OAuth 参数。您需要在 GET 或 POST 中提供 OAuth 参数。另一方面,Twitter 建议通过标头发送这些参数。

于 2011-05-04T07:29:06.077 回答