Facebook graph api 获取用户';s的朋友';个人资料图片
我正在尝试检索所有用户的好友档案图片,以在列表视图中呈现它们 我通过此图形请求获取应用程序中所有用户的好友:Facebook graph api 获取用户';s的朋友';个人资料图片,facebook-graph-api,react-native,Facebook Graph Api,React Native,我正在尝试检索所有用户的好友档案图片,以在列表视图中呈现它们 我通过此图形请求获取应用程序中所有用户的好友: `const infoRequest = new GraphRequest( '/me', { parameters: { fields: { string: 'email, name, first_name, middle_name,
`const infoRequest = new GraphRequest(
'/me',
{
parameters: {
fields: {
string: 'email, name, first_name, middle_name,
last_name, picture.type(large), cover, birthday, location, friends'
}
}
},
this._responseInfoCallback
);`
然后,我尝试用这个函数呈现他的朋友的个人资料图片
`renderFriends() {
if(this.state.user != null) {
return this.state.user.friends.data.map(friend =>
<View>
<Image
source={{uri:'https://graph.facebook.com/{friend.id}/picture?
type=large'}}
style={styles.profilePicture}
/>
<Text key={friend.id} >{friend.name}</Text>
</View>
)
}
}`
改变
借
{friend.id}
不会被friend id替换,它被解释为文本字符串{friend.id}
,这会给您错误的url
`profilePicture: {
height: 120,
width: 120,
borderRadius: 60,
marginTop: height / 15,
},`
{{ uri: 'https://graph.facebook.com/{friend.id}/picture?type=large' }}
{{ uri: 'https://graph.facebook.com/' + friend.id + '/picture?type=large' }}