首页 > 解决方案 > 如何使用颤振从 facebook graph api 获得更好的个人资料图片

问题描述

我正在使用 http.get 获取用户的 fb 个人资料图片,但图片非常小且模糊,我怎样才能获得更好的图片?目前这是我获取图像并存储它的代码:

final token = result.accessToken.token;
                          final graphResponse = await http.get('https://graph.facebook.com/v3.3/me?fields=name,picture,friends,email&access_token=${token}');
                          final profile = JSON.jsonDecode(graphResponse.body);
                          print(profile);
                          setState(() {
                            userProfile = profile;
                            _isLoggedIn = true;
                          });

然后当我在我的数据库中设置数据时:

'photoUrl':userProfile["picture"]["data"]["url"],

图片非常小而且模糊,因为我在 url idk 中得到了 50 的宽度和高度,但是如何改变它呢?

标签: facebook-graph-apiflutterdart

解决方案


有关指定维度的示例 URL,请参见下文。

final graphResponse = await http.get(
    'https://graph.facebook.com/v2.12/me?fields=name,picture.width(800).height(800),first_name,last_name,email&access_token=${fbToken}');

这确实是一个 FB Graph API 问题,之前已在此处回答:获取全尺寸个人资料图片


推荐阅读