经过漫长的学习过程后,我成功地使用Google API客户端库成功获取了用户的个人资料信息。
除了姓名和电子邮件地址,当用户登录我的网络应用程序时,我还可以获取他们的个人资料照片。
麻烦的是,图片非常大,尺寸和字节都很大。这样的图片的网址看起来像这样:
https://lh4.googleusercontent.com/-rdhxDPbmVhg/AAAAAAAAAAI/AAAAAAAAAJQ/6Dsr5psyQPs/photo.jpg
(是的,那是我在珊瑚城堡)。
有没有办法获得缩略图或图标大小的个人资料图片,就像我在Google搜索结果中看到作者旁边的那种?我注意到这些不是URL,而是数据对象,所以我可能不得不在php中做一些事情来将其渲染为图像?
作者的图片信息示例,在Google搜索的结果列表中,如下所示:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4QBgRXhpZgAASUkqAAgAAAACADEBAgAHAAAAJgAAAGmHBAABAAAALgAAAAAAAABQaWNhc2EAAAMAAJAHAAQAAAAwMjIwAqAEAAEAAAAsAAAAA6AEAAEAAAAsAAAAAAAAAP/bAIQAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsVFhAUExQVFRcMDxcUFhQTFxQVEAEDBAQGBQYJBgYKEg0LDhIVEBAQFBEQEw8UDhUQFRAQDxAQDxEQFA8NEA8QDQ0QDw0ODBAQEAwMDBAPDw8MDA8P/8AAEQgALAAsAwERAAIRAQMRAf/EABkAAAMBAQEAAAAAAAAAAAAAAAYHCAkFAf/EADIQAAEDAwIEBAQFBQAAAAAAAAECAwQFBhEAIQcSMUETIlGBCCNxkRQyYZLBFTNSocL/xAAaAQACAwEBAAAAAAAAAAAAAAAEBQIDBgcB/8QALxEAAQMDAQQJBAMAAAAAAAAAAQACAwQRITEFEkFREyJhcYGRobHBFCPR8EJi4f/aAAwDAQACEQMRAD8AzPjsKlQ6iAQCGEn7vtJ/61DSytOiZPDHgA5xImRk0tmS/F5EeNIkHw0BePOBjGwPfOdKKiv6G4da/Ls4J3Q7MdUAG2Oaf1b+A56ZbzjdM/prM5Ke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zcyFEkrRyq+alSAopwfXYHOq4WDfF9PhC1MpDHEageqkHjtw5pF30mFUKk6+mWuap1ciK2hLrylIVzKcUUkqz5M9D5RvnpoKd5jkeOAGnZjRY+Zom3OBcde08SuFaPw8WbIowVJo635AedQtanXVZKVkdlbYAG2iTVdJ1o7gcsXHevZaD6d5iebkcQDY4vi6T9lXbSLMqjsipBS47sZxrwhjzqJGM5I21HonSRSMGrhZDTlolheP4u3jz0Ix25RVwxvo0mh1BFNTLqEJh1YlPK5PD5MoUhQwonPXm9OZPXzECu2dI4Em2OX++KdDa0W8N0HPO3Pv1tYKruFXFK34sSP4clyRKcSUiKwlSnE+g5cbe+NK/p36OTZ1ZHa7U97Itx7iO3VEz21Q4LzS2VNEBXgNrSUkq7FZBOB/GmFLROneAzQan4HaktXXiBhc/U6D5Uo8ebiiUC559pNxXJEmLVH0pbV2ZQvyEHPXBT+7Vs8JZJIB3fvglVLXQEMdKSLEE4S0l1enNTJJRUqpHccdWtxqI4EISoqONt9+Xl++NRgiYGDfAv4/Bzy8AmNbtkSzF0Uh3MW6o0t/YX1ufFJywYcSoypQnxGZ7CUgmPIBKF9Tg4IPUDvphNgsAxql8ZvFKT2e6aPCWDBlcK1uNwI0QTXJ7jjbCMJHIlsAAEnY4Gc56DGNH5ZTyPBz+lLo7PmjYRgo94I1F2Bbi6k0EfjGo5KHFJzg6QTCxstNHkAquaNKVZFfuybTAA5CoUqQEOkqS8tnkU2XBkc2+T7n110EsbBT7rBhuQubzPdLIXuOTqoNZqcq4K1Xq9UX1zKq86ouSHdypR86j9SpRz7emsHK4m1+OSiHYACXNQqDzUlRSrdz5iie6judXNaCEaBhf/9k=
如果需要,我欢迎帮助我澄清这个问题。
答案 0 :(得分:7)
您可以通过在您获得的网址上附加?sz=(size in pixels)
参数来调整图片大小。
实施例
https://lh4.googleusercontent.com/-rdhxDPbmVhg/
AAAAAAAAAAI/AAAAAAAAAJQ/6Dsr5psyQPs/photo.jpg?sz=50
将显示为
您使用什么方法来检索用户信息?
经过身份验证的用户使用userId=me
调用的people.get method of the Google+ API已经返回了在响应的?sz=50
字段中添加了image.url
参数的网址。
答案 1 :(得分:2)
只需将尺寸参数传递给网址?sz=200
它会变成https://lh3.googleusercontent.com/--sahsjak8sjdbs5kNk/AAAAdshjgdshdgAAI/AAAAsdhsHY/knQ6LGqP1Yk/photo.jpg?sz=200
你很高兴去!