小编use*_*891的帖子

获取请求strava v3 api python的活动

编辑 - 因为我无法用Strava标记这里,如果你感兴趣的话,这里是文档 - http://strava.github.io/api/

我完成了身份验证,并在response.read中获取了access_token(以及我的运动员信息).

我在下一步遇到问题:我想返回有关特定活动的信息.

    import urllib2
    import urllib

    access_token = str(tp[3]) #this comes from the response not shown
    print access_token

    ath_url = 'https://www.strava.com/api/v3/activities/108838256'

    ath_val = values={'access_token':access_token}

    ath_data = urllib.urlencode (ath_val)

    ath_req = urllib2.Request(ath_url, ath_data)

    ath_response = urllib2.urlopen(ath_req)

    the_page = ath_response.read()

    print the_page
Run Code Online (Sandbox Code Playgroud)

错误是

    Traceback (most recent call last):
      File "C:\Users\JordanR\Python2.6\documents\strava\auth.py", line 30, in <module>
        ath_response = urllib2.urlopen(ath_req)
      File "C:\Users\JordanR\Python2.6\lib\urllib2.py", line 124, in urlopen
        return _opener.open(url, data, timeout)
      File "C:\Users\JordanR\Python2.6\lib\urllib2.py", line 389, in open
        response = meth(req, response) …
Run Code Online (Sandbox Code Playgroud)

python api urllib urllib2

3
推荐指数
1
解决办法
3798
查看次数

标签 统计

api ×1

python ×1

urllib ×1

urllib2 ×1