0

虽然我能够通过授权接收初始 Strava oAuth 代码?Strava 页面上的流程,我正在努力解决此处描述的令牌交换流程:https ://developers.strava.com/docs/authentication/

下面的代码只会导致

Sorry, this one stays red.
The page you’re looking for doesn’t exist, but you’re not at a dead end. 
Here are a few options:

Be sure you have the right url and try again
Sign up or log in at strava.com
See what the community’s been up to at Strava Stories
Search for a particular activity or club
Get a little help from Strava Support

我对 Strava API 很陌生,但在浏览器中直接粘贴生成的 URL 确实会导致相同的页面响应。

$url = "https://www.strava.com/oauth/token?client_id=XXXXX&client_secret=XXXXXXXXXXXXXXXXXXXXXXXX&code=".$code."&grant_type=authorization_code";

echo "<br />".$url;

$cURL = curl_init();

curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));

$result = curl_exec($cURL);

curl_close($cURL);



print_r($result);

?>

预先感谢您对此事的支持!

4

1 回答 1

0

@Chris White 解决了这个问题,使用的是 POST 而不是 GET。谢谢您的帮助

echo "<br />".$url;

$cURL = curl_init();

curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_POST, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));

$result = curl_exec($cURL);

curl_close($cURL);



print_r($result);

?>
于 2019-05-20T05:01:34.577 回答