通过 iPhone 的 DropBox SDK 在 Objective C 中创建 JSON 请求 URL

发布于 2024-10-27 05:09:41 字数 291 浏览 0 评论 0原文

我对尝试弄清楚 JSON 和 DropBox API 如何与 DB 为 iPhone 发布的 iphone SDK 一起工作还很陌生。我了解这两种技术一般是如何工作的,并且您必须在请求中构建一个字典并获取另一个字典,但是我找不到一个可靠的示例来说明如何在 Objective C 中在线足够具体地执行任何操作。

我只需要一个例如,如何通过创建 JSON 请求从投递箱服务器获取信息来检索用户的个人资料信息。

我已经能够使用消费者密钥和消费者秘密登录用户并链接设备,但接下来我有点不知所措。

非常感谢您提供任何指导或示例。

I'm rather new to trying to figure out how JSON and the DropBox API function with the iphone SDK that DB has release for the iPhone. I understand how both technologies work in general and that you have to build a dictionary into a request and get another dictionary back, but I can't find a solid example of how to do anything specifically enough online in Objective C.

I just need one example of how to retrieve for instance the user's profile information by creating a JSON request to fetch info from the drop-box server.

I've been able to log the user in and linking the device using the consumer key and consumer secret but what's next I'm a little at a loss.

MANY thanks for any guidance or examples.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似最初 2024-11-03 05:09:41

发送数据

POST 方法示例:

url = @"https://api.dropbox.com/<version>/account/"
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:value forKey:@"callback"];

GET 方法示例(URL 查询):

  NSString *urlString = [[[NSString alloc] initWithString:@"https://api.dropbox.com/<version>/account/info
"] autorelease];
    urlString = [urlString stringByAppendingFormat:@"?callback=whatever&status_in_response=something"];
    NSURL *url = [[NSURL alloc] initWithString:urlString];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(requestDidFinishForThreadID:)];
    [request startAsynchronous];

检索 JSON 值并将其转换为字典

SBJsonParser *json = [[SBJsonParser alloc] init];
NSDictionary *dict = (NSDictionary*)[json objectWithString:responseString];

您将需要 JSON 框架:http://code.google.com/p/json-framework/

还有 ASIHTTPRequest:http://allseeing-i.com/ASIHTTPRequest/

尚未使用 dropbox 进行测试,但应该是这样。

To send your data

Example for POST methods:

url = @"https://api.dropbox.com/<version>/account/"
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:value forKey:@"callback"];

Example for GET methods (URL queries):

  NSString *urlString = [[[NSString alloc] initWithString:@"https://api.dropbox.com/<version>/account/info
"] autorelease];
    urlString = [urlString stringByAppendingFormat:@"?callback=whatever&status_in_response=something"];
    NSURL *url = [[NSURL alloc] initWithString:urlString];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(requestDidFinishForThreadID:)];
    [request startAsynchronous];

To retrieve JSON values and convert them into Dictionary

SBJsonParser *json = [[SBJsonParser alloc] init];
NSDictionary *dict = (NSDictionary*)[json objectWithString:responseString];

You will need JSON Framework: http://code.google.com/p/json-framework/

And also ASIHTTPRequest: http://allseeing-i.com/ASIHTTPRequest/

Haven't tested it with dropbox, but should be this way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文