如何在Facebook图形api请求中设置个人资料图片的特定尺寸?

问题描述 投票:0回答:1

我试图将参数设置为picture.width(360).height(360)

const infoRequest = new GraphRequest(
                '/me',
                {
                    accessToken: tokenData.accessToken,
                    parameters: {
                        fields: {
                            string: 'id,email,name,picture.width(360).height(360)'
                        }
                    }
                },
                responseInfoCallback
            );

但是返回的尺寸不正确480x480

{
    "profile":{
      "picture":{
         "data":{
            "width":480,
            "height":480,
            "url":"https://scontent.fmnl3-1.fna.fbcdn.net/v/t1.30497-1/c141.0.480.480a/p480x480/84628273_176159830277856_972693363922829312_n.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_eui2=AeF95aCnm2ggUPNPmTv9zCouik--Qfnh2B6KT75B-eHYHvMDChmr6ZbCJUK-KjNtt6PEAlHLBWx9GsGneBpfz-Jm&_nc_ohc=VQqsNSqP_MgAX_0Hjw6&_nc_ht=scontent.fmnl3-1.fna&oh=f11455cd5e09ac5466f5b7590d489e7e&oe=5EDF5715",
            "is_silhouette":true
         }
      },
      "id":"102794254765525",
      "name":"Elizabeth Aleajdheafejh Fallerwitz",
      "email":"[email protected]"
   }
}

任何帮助将不胜感激

facebook-graph-api backend
1个回答
1
投票

您可以使用此。

  const user = {
              "name": getUser.name,
              "firstName":getUser.first_name,
              "lastName": getUser.last_name,
              // "profileImage": getUser.picture.data.url,
profileImage:`http://graph.facebook.com/${getUser.id}/picturetype=large&redirect=true&width=500&height=500`,
               "token": data.accessToken,
               }

如果有任何问题,请问。

© www.soinside.com 2019 - 2024. All rights reserved.