> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFFriendsClientAddFriendAsync

> 根据针对所提供的唯一标识符的匹配，将 PlayFab 用户添加到本地用户的好友列表中。至少应初始化以下之一。

根据针对所提供的唯一标识符的匹配，将 PlayFab 用户添加到本地用户的好友列表中。应至少初始化 FriendPlayFabId、FriendUsername、FriendEmail 或 FriendTitleDisplayName 之一。

## 语法

```cpp theme={null}
HRESULT PFFriendsClientAddFriendAsync(  
    PFEntityHandle entityHandle,  
    const PFFriendsClientAddFriendRequest* request,  
    XAsyncBlock* async  
)  
```

### 参数

**`entityHandle`**   PFEntityHandle

用于身份验证的 PFEntityHandle。

**`request`**   [PFFriendsClientAddFriendRequest\*](/services/playfab/api-references/c/pffriendstypes/structs/pffriendsclientaddfriendrequest)

已填充的请求对象。

**`async`**   XAsyncBlock\*<br />*Inout*

用于异步操作的 XAsyncBlock。

### 返回值

类型：HRESULT

此 API 操作的结果代码。

## 备注

此 API 在所有平台上均可用。另请参阅 ClientGetFriendsListAsync、ClientSetFriendTagsAsync。当异步任务完成时，请调用 [PFFriendsClientAddFriendGetResult](/services/playfab/api-references/c/pffriends/functions/pffriendsclientaddfriendgetresult) 以获取结果。

## 要求

**头文件：** PFFriends.h

## 另请参阅

[PFFriends 成员](/services/playfab/api-references/c/pffriends/pffriends_members)


## Related topics

- [PFFriendsClientAddFriendGetResult](/zh-CN/services/playfab/api-references/c/pffriends/functions/pffriendsclientaddfriendgetresult.md)
- [Services C API overview - PFFriends.h](/zh-CN/services/playfab/api-references/c/pffriends/pffriends_members.md)
- [PFFriendsClientRemoveFriendAsync](/zh-CN/services/playfab/api-references/c/pffriends/functions/pffriendsclientremovefriendasync.md)
- [PFFriendsClientGetFriendsListAsync](/zh-CN/services/playfab/api-references/c/pffriends/functions/pffriendsclientgetfriendslistasync.md)
- [PFFriendsClientAddFriendRequest](/zh-CN/services/playfab/api-references/c/pffriendstypes/structs/pffriendsclientaddfriendrequest.md)
