如何使用适用于 iPad 的 Apple IOS 设置 Basecamp 凭据
我正在尝试请求我公司的 Basecamp 信息来了解我们正在构建的内部项目。我了解如何在 ASP.NET 环境中添加凭据,但我是 iPad 开发新手,似乎无法从 Basecamp 获得适当的响应。这就是我正在做的:
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mybasecampname.basecamphq.com/projects.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0 ];
我正在添加 Bsaecamp 所需的 HTTP 标头,如下所示:
[theRequest setValue:@"application/xml" forHTTPHeaderField:@"Content-Type" ];
[theRequest setValue:@"application/xml" forHTTPHeaderField:@"Accept" ];
我知道我还需要发送我的凭据以进行身份验证 - 我的身份验证令牌和我喜欢的任何密码,但我不确定最好的方法来做到这一点。这就是我正在尝试的:
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"MY TOKEN HERE"
password:@"x"
persistence:NSURLCredentialPersistenceForSession];
我的问题是:我是否走在正确的轨道上,还是我完全错过了一些东西?
以下是 Basecamp API 详细信息的链接,其中解释了它的需求: http://developer.37signals.com/basecamp/
帮助表示赞赏。
乔
I'm trying to request my company's Basecamp info for an internal project we're building. I understand how to add credentials in an ASP.NET environment but I'm new to iPad development and can't seem to get an appropriate response from Basecamp. Here's what I'm doing:
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mybasecampname.basecamphq.com/projects.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0 ];
I'm adding the HTTP headers that Bsaecamp requires like so:
[theRequest setValue:@"application/xml" forHTTPHeaderField:@"Content-Type" ];
[theRequest setValue:@"application/xml" forHTTPHeaderField:@"Accept" ];
I know I also need to send my credentials for authentication purposes - my authentication token and any password I like but I'm not sure the best way to do this. Here's what I'm trying:
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"MY TOKEN HERE"
password:@"x"
persistence:NSURLCredentialPersistenceForSession];
My question is: Am I on the right track here or am I missing something completely?
Here's a link to the Basecamp API details which explains what it needs: http://developer.37signals.com/basecamp/
Help appreciated.
Joe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一如既往,我最终解决了这个问题。一旦我开始使用 didReceiveAuthenticationChallenge 方法,事情就开始步入正轨。
所以。我简化了我的请求方法:
然后设置一个用于接收身份验证质询的方法:
然后设置一个 didReceiveData 方法来捕获返回的数据:
希望这对其他人有帮助。
仍然很高兴听到这个
JJ有更好的方法
As is always the way, I worked it out eventually. Once I started using the didReceiveAuthenticationChallenge method things started to fall into place.
So. I simplified my request method:
and then set up a method for receiving the authentication challenge:
then set up a didReceiveData method to catch the data returned:
Hope this helps someone else out there.
Still happy to hear better method for this
JJ