是否可以编写代码加载特定 URL 然后获取返回的 URL 的方式。例如,当我加载此 URL https://id.twitch.tv/oauth2/authorize?client_id=8g11d1v5x70s2ql86wyownczj6hfc0&redirect_uri=http%3A%2F%2Flocalhost%2FSocialMediaSite%2FSite%2FHome&response_type=code&scope=user%3Aread%3Aemail&state=b32389173246992
URL 更改为 http://localhost/SocialMediaSite/Site/Home?code=kgegrwigrj5i8mm2vdktwstrbmwivg&scope=user%3Aread%3Aemail&state=742a4bf34bea19022074f92680966cc3
这是因为 twitch 正在运行 api 并将返回 url 作为结果返回给该页面。但是有没有办法自动做到这一点?我试过了
if($('.LoadStreamers').length){
$.get('../Admin/TwitchAPI/getFollowers.php',function(data){
console.log(data);
$.get(data,function (data2){
console.log(data2);
})
})
}
我得到的结果是
https://id.twitch.tv/oauth2/authorize?client_id=8g11d1v5x70s2ql86wyownczj6hfc0&redirect_uri=http%3A%2F%2Flocalhost%2FSocialMediaSite%2FSite%2FHome&response_type=code&scope=user%3Aread%3Aemail&state=b5dcc70324892f0d3987936f9332d811
Access to XMLHttpRequest at 'https://www.twitch.tv/login?client_id=8g11d1v5x70s2ql86wyownczj6hfc0&redirect_params=client_id%3D8g11d1v5x70s2ql86wyownczj6hfc0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%252FSocialMediaSite%252FSite%252FHome%26response_type%3Dcode%26scope%3Duser%253Aread%253Aemail%26state%3Db5dcc70324892f0d3987936f9332d811' (redirected from 'https://id.twitch.tv/oauth2/authorize?client_id=8g11d1v5x70s2ql86wyownczj6hfc0&redirect_uri=http%3A%2F%2Flocalhost%2FSocialMediaSite%2FSite%2FHome&response_type=code&scope=user%3Aread%3Aemail&state=b5dcc70324892f0d3987936f9332d811')
from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
jquery.min.js:4 GET https://www.twitch.tv/login?client_id=8g11d1v5x70s2ql86wyownczj6hfc0&redirect_params=client_id%3D8g11d1v5x70s2ql86wyownczj6hfc0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%252FSocialMediaSite%252FSite%252FHome%26response_type%3Dcode%26scope%3Duser%253Aread%253Aemail%26state%3Db5dcc70324892f0d3987936f9332d811 net::ERR_FAILED