Skip to content

Instantly share code, notes, and snippets.

@leonhandreke
Created August 29, 2016 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonhandreke/98041d9f3b2bdbd65d471213133d2758 to your computer and use it in GitHub Desktop.
Save leonhandreke/98041d9f3b2bdbd65d471213133d2758 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
# your Strava login details go here
EMAIL=leonh@ndreke.de
PASSWORD=your_secret_password
FILE=$1
CURL="curl --cookie /tmp/strava-cookies.txt --cookie-jar /tmp/strava-cookies.txt"
# get login page
AUTH=$($CURL -k https://www.strava.com/login | grep 'name="authenticity_token"' | sed 's/.*value="\(.*\)".*/\1/g')
echo "AUTH=$AUTH"
# login
$CURL -k --data-urlencode "utf8=✓" --data-urlencode "authenticity_token=$AUTH" --data-urlencode "plan=" --data-urlencode email="${EMAIL}" --data-urlencode password="${PASSWORD}" --data-urlencode "remember_me=on" https://www.strava.com/session
# go to upload page
$CURL http://www.strava.com/upload/select | grep "authenticity_token"
# send file
$CURL -F "_method=post" -F "authenticity_token=$AUTH" -F "files[]=@$FILE" http://www.strava.com/upload/files
# logout
$CURL --data-urlencode "_method=delete" --data-urlencode "authenticity_token=$AUTH" http://www.strava.com/session
rm /tmp/strava-cookies.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment