1

我正在尝试执行以下操作:

curl -H "authorization: 49a74aebda84ffe1f7ebe25cb2c5e3fa1013dd76" -X GET http://mywebsite.com/api/v1/tags

这是我的代码:

   dataRequest = [ASIFormDataRequest requestWithURL:url];
    [dataRequest setDelegate:self];
    [dataRequest setRequestMethod:@"GET"];
    [dataRequest addRequestHeader:@"Authorization" value:api_key];
    [dataRequest setPostValue:url forKey:@"url"];
    [dataRequest startAsynchronous];

我没有得到有效的 JSON,并想确保我正确发送请求。我已确保 api_key 和 url 有效。

4

2 回答 2

3

您的代码示例不应使用ASIFormDataRequest. 它应该使用ASIHTTPRequest.

dataRequest = [ASIHTTPRequest requestWithURL:url];
[dataRequest setDelegate:self];
[dataRequest addRequestHeader:@"Authorization" value:api_key];
[dataRequest startAsynchronous];
于 2012-05-08T17:55:24.970 回答
-1
dataRequest = [ASIHTTPRequest requestWithURL:url];

[dataRequest setDelegate:self];

[dataRequest addRequestHeader:@"Authorization" value:api_key];

[dataRequest startAsynchronous];
于 2014-02-07T06:58:25.150 回答