对于那些有使用 Strava API 经验的人 - 我使用了他们开发者网站上的文档:https ://developers.strava.com/docs/reference/#api-Activities-getLoggedInAthleteActivities
但是,复制他们的代码我得到一个属性错误-
AttributeError: 'ActivitiesApi' object has no attribute 'getActivityById'
AttributeError: 'ActivitiesApi' object has no attribute 'getLoggedInAthleteActivities'
知道为什么吗?显然从他们的网站输入了我的 ID/秘密/令牌。下面的代码:
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
STRAVA_CLIENT_ID = MY_CLIENT_ID
STRAVA_CLIENT_SECRET = 'MY_CLIENT_SECRET'
STRAVA_ACCESS_TOKEN = 'MY_ACCESS_TOKEN'
swagger_client.configuration.access_token = STRAVA_ACCESS_TOKEN
api_instance = swagger_client.ActivitiesApi()
def get_activity_data():
activity_id = 3307145226
includeAllEfforts = True # Boolean | To include all segments efforts. (optional)
try:
# Get Activity
api_response = api_instance.getActivityById(id,
includeAllEfforts=includeAllEfforts)
pprint(api_response)
except ApiException as e:
print("Exception when calling ActivitiesApi->getActivityById: %s\n" % e)
return