OGeek|极客世界-中国程序员成长平台

标题: ios - 适用于 iOS 的 Garmin Connect API [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:06
标题: ios - 适用于 iOS 的 Garmin Connect API

我正在尝试创建一个库以从 Garmin Connect 下载内容。

没有太多文档,或者不公开,但我尝试将我的代码基于伟大的 Tapiriik project

Garmin API 似乎需要创建一个 session (基于 BasicAutentication cookie)才能下载内容。

我尝试使用 NSURLConnection 和 NSURLSession 不成功(Sync/Async & With delegate 和 CompletionHandler 也尝试过)。

// POST request with the params I have found on the tapiriik example
[NSMutableURLRequest requestWithURL:[NSURL URLWithString"https://connect.garmin.com/signin"]];
NSString *post = [NSString stringWithFormat"j_id1=javax.faces.ViewState&login=login&login:loginUsernameField=%@&login:password=%@&login:signInButton=Sign In", theUsername, thePassword];
[request setHTTPMethod"OST"];
[request setHTTPBody:[post dataUsingEncoding:NSUTF8StringEncoding]];
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

响应是 200,我检查了用户配置文件,似乎可以成功运行。但如果我尝试下载事件,我会收到 403

request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString"https://connect.garmin.com/proxy/activity-search-service-1.2/json/activities?start=0&limit=10"]];
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

PD:我检查了其他 github 项目,但它们都以与 Tapiriik 代码相似的方式工作

有什么建议吗?



Best Answer-推荐答案


我终于解决了。 Garmin 似乎有了新的发展政策。

最后我按照这里的步骤操作:https://forums.garmin.com/showthread.php?72150-connect-garmin-com-signin-question&p=264580#post264580

我会将代码上传到GitHub并在这里分享。

问候

关于ios - 适用于 iOS 的 Garmin Connect API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23859610/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4