gpt4 book ai didi

javascript - Google Signin getImageUrl() 图像大小

转载 作者:行者123 更新时间:2023-11-28 04:40:09 25 4
gpt4 key购买 nike

我正在向我的网站添加谷歌登录,但找不到任何文档来解释如何指定 getBasicProfile() 代码中 getImageUrl() 返回的图像的大小。这是我正在使用的代码:

function startApp() {
gapi.load('auth2', function(){
auth2 = gapi.auth2.init({
client_id: 'apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
});
attachSignin(document.getElementById('gLogin'));
});
};

startApp();

function attachSignin(element) {
auth2.attachClickHandler(element, {}, function(googleUser) {
var profile = googleUser.getBasicProfile();
$.ajax({
type:'POST',
url: '/example.com',
data: {
ID: profile.getId(),
firstName: profile.getGivenName(),
lastName: profile.getFamilyName(),
profileImage: profile.getImageUrl(),
emailAddress: profile.getEmail(),
tokenID: googleUser.getAuthResponse().id_token,
formID: 'gLogin'
},
success:function(data) {
if (data == 'success') {
window.location.reload(false);
}else{
alert(data);
}
},
error: function() {
alert('There was an error in our system! Please try again later.');
}

}) // End of Ajax Code

}, function(error) {
alert(JSON.stringify(error, undefined, 2));
});
}

本质上,这段代码非常适合我的情况,但 profile.getImageUrl() 返回的图像返回 50px 图像。如何指定需要返回的尺码?有办法吗?

谢谢!

最佳答案

在 Google 为您提供的网址中,将“s96-c”替换为“sX-c”,其中 X 是您想要的图像尺寸。我有点惊讶这对我来说很难找到。一定花了一两个小时四处寻找答案。最终在这里找到它:https://stackoverflow.com/a/55630187/2576959

关于javascript - Google Signin getImageUrl() 图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43856467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com