No wlasnie sledze i sledze i niemoge sie dosledzic tego:
https://www.strava.com/login
function getAuthenticityToken(){
$fo = fopen('cookie.txt', 'w'); $ch = curl_init();
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, 'https://www.strava.com/login');
// curl_setopt($ch, CURLOPT_POST, 1);
// curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_REFERER, "http://www.strava.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
$response = curl_exec($ch);
curl_close ($ch);
$authenticity_token = explode('content=', $matches[0
][5
]); $authenticity_token = explode('name=', $authenticity_token[1
]); $authenticity_token = str_replace('"', '', $authenticity_token[0
]); return $authenticity_token;
}
function login($site, $email, $password){
$post_data ='email='.urlencode($email).'&password='.$password. '&authenticity_token='.urlencode(getAuthenticityToken
()).'&plan=&utf8=%E2%9C%93';
$fo = fopen('cookie.txt', 'w'); $ch = curl_init();
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $site);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_REFERER, 'https://www.strava.com/login');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
$response = curl_exec($ch);
curl_close ($ch);
return $response;
}
echo login
('https://www.strava.com/login','x', 'x');
Jakies pomysly jak to inaczej rozwiazac?