尝试使用Google个人资料图片加载img src时出现HTTP:403禁止的错误 [英] http:403 forbidden error when trying to load img src with google profile pic
问题描述
大家好,我正尝试在我的网站和其他网站中加载google个人资料图片
hello everyone I am trying to load google profile picture in my site and other ones
我做完
var profile = googleUser.getBasicProfile();
profile.getImageUrl()
当我使用google登录并将图像url保存到数据库中时,但是当我尝试将其放入img标签的scr中时
when I sign in with google and save the image url to a database but when I try to put it into the scr of an img tag like so
var img = document.createElement("img");
img.src = image;
img.alt = "image";
img.style.float = "left";
divn.appendChild(img);
我有时会收到403禁止的错误,但有时它会起作用 这是一个示例链接,我正在使用存储在数据库中的链接,只是做了一点改动
I get 403 forbidden error sometimes, but sometimes it works here is a sample link that I'm using the one that is stored in the database just altered a bit
https://lh4.googleusercontent.com/-OmV9386WzGk/AAAAFFFFAAI/AAAAAAAACpc/BEtVNh85tnk/s96-c/photo.jpg
所以我只是想知道我是否正在正确地获取个人资料图片,以及其他用户是否也在同一页面上
so I'm just wondering if I'm doing it right obtaining the profile image, and its for other users also on the same page
推荐答案
使用 似乎有帮助.尽管它在localhost应用程序中不起作用(在添加此属性之前),但在将图像加载到其自己的选项卡中时,它始终有效.请求标头中的差异之一是缺少referer
.
这篇关于尝试使用Google个人资料图片加载img src时出现HTTP:403禁止的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!