我对 ORCID 和 API 请求很陌生,所以如果我的问题的答案很明显,我很抱歉。我正在尝试在我的网站上实施 ORCID 身份验证系统,但是当我应该收到一些有关进行身份验证的用户的信息时,我收到了 301 错误。
我已将登录按钮放在第一页:
<button id="connect-orcid-button" onclick="openORCID()"><img id="orcid-id-icon" src="https://orcid.org/sites/default/files/images/orcid_24x24.png" width="24" height="24" alt="ORCID iD icon"/>Se connecter ou s'enregistrer avec un ORCID iD</button>
function openORCID() {
var oauthWindow = window.open("http://orcid.org/oauth/authorize?client_id=[MyClientId]&response_type=code&scope=/authenticate&redirect_uri=http://localhost/MASA_openGuide/openGuide/portal.php", "_blank", "toolbar=yes, scrollbars=yes, width=500, height=600, top=500, left=500");
}
单击时,它运行良好,我可以毫无问题地进行身份验证,并将我发送到第二页,我在其上设置了此代码以获取信息,这要归功于令牌:
$code = $_GET["code"];
echo $code;
$lien = 'http://orcid.org/oauth/token';
$header = array(
'Accept' => 'application/json',
);
$postField = array(
'url' => 'http://orcid.org/oauth/token',
'client_id' => [myClientId],
'client_secret' => [myClientSecret],
'grant_type' => 'client_credentials',
'scope' => '/read-public'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $lien);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postField);
$result = curl_exec($curl);
curl_close($curl);
然后我收到错误“301 Moved Permanently”,在 ORCID 网站上显示“此 ORCID iD 已被弃用,如果您没有自动转发,请查看更新后的 ORCID iD 的返回位置”。但我不确定我应该做什么:/ 目标只是获取记录以在网站上发布一些此类信息并将它们存储在 cookie 中。
我希望我成功地清楚了。
非常感谢您的帮助,如果答案很明显,再次抱歉...