php - 你能在 JQuery 或 PHP 中通过 GET 获得返回 URL 吗?
问题描述
是否可以编写代码加载特定 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
解决方案
推荐阅读
- generator - 无法映射时间戳类型--mybatis 生成器
- android - 在 ViewStub Android 中查找控件
- css - 当我点击播放时,如何在网站上膨胀嵌入的 youtube 视频帧?
- pyspark - How do I select columns from a Spark dataframe when I also need to use withColumnRenamed?
- c# - Azure 逻辑应用接收图像 HTTP 触发器
- c# - MSI 安装程序选项 - 卸载应用程序
- c# - 集合未过滤 WPF 中的列表项
- matlab - Matlab中输入的确定是真实的
- sql - 提高 SQL 查询的性能
- c++ - 在 C++ 中输入多个整数时如何错误检查空格和小数?