Strava API guide
1) Access Token 받아오기
https://javascript.plainenglish.io/strava-api-react-app-326e63527e2c?gif=true
https://jessicasalbert.medium.com/holding-your-hand-through-stravas-api-e642d15695f2
https://developers.strava.com/docs/getting-started/
Strava Settings/API
https://www.strava.com/settings/api
Strava API test : postman
Swagger UI :
https://developers.strava.com/playground/#/
2) C# 코드로 받아오기
- Strava Dotnet : https://github.com/chrisbarber7/stravadotnet/
Test Code :
using Strava.Activities;
using Strava.Athletes;
using Strava.Authentication;
using Strava.Clients;
using System;
using System.Collections.Generic;
namespace TestStrava
{
class Program
{
static void Main(string[] args)
{
StaticAuthentication auth = new StaticAuthentication("----");
StravaClient client = new StravaClient(auth);
//Receive all the comments
ActivityClient test = client.Activities;
List<ActivitySummary> list = test.GetActivities(1, 5);
Console.WriteLine(String.Format("List Count : {0}", list.Count));
foreach (ActivitySummary summary in list)
{
Console.WriteLine(String.Format("Name : {0}, Athlete: {1} Start Date : {2}", summary.Name, summary.Athlete.Id, summary.StartDate));
}
}
}
}
아래 같이 볼 수 있다.(Athlete.Id로 출력할 것.)
Acitivites에서 확인할 수 있는 데이터 =->
{
"resource_state": 2,
"athlete": {
"id": 24554267,
"resource_state": 1
},
"name": "Evening Walk",
"distance": 5057.4,
"moving_time": 4131,
"elapsed_time": 4229,
"total_elevation_gain": 112.8,
"type": "Walk",
"id": 6660525777,
"start_date": "2022-02-10T10:40:59Z",
"start_date_local": "2022-02-10T19:40:59Z",
"timezone": "(GMT+09:00) Asia/Seoul",
"utc_offset": 32400,
"location_city": null,
"location_state": null,
"location_country": null,
"achievement_count": 0,
"kudos_count": 0,
"comment_count": 0,
"athlete_count": 1,
"photo_count": 0,
"map": {
"id": "a6660525777",
"summary_polyline": "istcFc{{eWNIj@OTJJJJVb@j@HAb@Nv@bBXd@Xp@Pr@Dz@BHTPzA_@r@Bt@Zd@@h@RFCb@Dn@VPLj@r@j@h@v@x@\\Xn@X@`@DJHBHX?RGh@PP@JG`@AZI\\Cz@Ol@[h@g@VMDc@B_AOc@AYEk@Ac@I}Am@YQaAa@MKs@AGCIQYCe@P_BNM?EBc@Fm@h@[f@Wh@ERGf@At@`@lEAbBBJ?xABXLr@@f@AX?t@JtAWRAFd@fE?XJfAAHGHYHu@@kAN[CQOMM_@aAg@w@Sm@S_@Y]Qe@?IMUa@m@Mc@IOMa@a@}@YQOOg@q@OIa@c@KG]K]SKCE@e@OE?u@SWEGEk@MOGW?UISA{@WYCMGyAYkBg@OA]K]QMAOGI?CC]GeAGgBDWDKDEFa@@MFU@EJIDWCOBIHYAC@EFi@BEFE@GC]LGHKCO?OGOAg@@S@MJEJIGo@?UTc@DQDYCSRUDENEDsAMuAAm@KC@GJ[DYEKGK?IC]FGAMFG?KGI?IEc@Gg@HUNOACBKB_@K[A]Ii@EYIq@@QICEKa@Aa@IHEAGKGCSES@GQQAOLUS_@SGOGBEF@KGCi@U@AG?GCEMWOUM]KIAOGQSI[C?OKa@MMMBYCCKAGE_@[Wi@]]s@WKAOMIKSCU?OKWY[Om@m@OIS]QKCU?EEA?IEAUAg@g@QUe@OW[EOMQKKED?LK`@?NLJH?j@n@\\TNZ?NMb@Gt@Hn@?NKZATCJAx@ETC`@Mp@?NFREd@Kf@DVGn@QX?LMfAEDCJARIn@?VCHGh@@f@",
"resource_state": 2
},
"trainer": false,
"commute": false,
"manual": false,
"private": false,
"visibility": "everyone",
"flagged": false,
"gear_id": null,
"start_latlng": [
37.47,
126.96
],
"end_latlng": [
37.49,
126.95
],
"start_latitude": 37.47,
"start_longitude": 126.95,
"average_speed": 1.224,
"max_speed": 3.426,
"average_cadence": 56.7,
"has_heartrate": true,
"average_heartrate": 83.9,
"max_heartrate": 112,
"heartrate_opt_out": false,
"display_hide_heartrate_option": true,
"elev_high": 134.2,
"elev_low": 40.9,
"upload_id": 7083085315,
"upload_id_str": "7083085315",
"external_id": "garmin_push_8270870669",
"from_accepted_tag": false,
"pr_count": 0,
"total_photo_count": 0,
"has_kudoed": false
},
이걸 유니티에서 그대로 사용해서 그려볼 수 있다.
(StravaDotnet.dll을 유니티 플러그인으로 사용. NewtonJson dll이 버전이 맞지 않아 새로 버전을 맞춰 빌드한 후 넣었다.)
728x90
'Software Development > C#' 카테고리의 다른 글
C# Post Example (0) | 2022.03.06 |
---|---|
유니티 3D 간보기 - 골드메탈 3D강좌:이펙트/아이템 생성 (0) | 2022.02.05 |
.Net Framework Guideline - Type Design(형식 디자인)-2 (0) | 2021.08.30 |
.Net Framework Guideline - Type Design(형식 디자인)-1 (0) | 2021.08.30 |
.Net Framework Guideline - Member Design-3 (0) | 2021.08.30 |