For the complete documentation index, see llms.txt. This page is also available as Markdown.

개요

Decentraland 플랫폼에서 우정, 요청 및 상호 친구를 가져오기 위해 Social Service API를 사용하는 방법에 대한 세부 정보입니다. 이 API를 통해 개발자는 Social Service와 상호작용하여 우정 관련 정보를 가져올 수 있습니다.

REST API

우정을 가져오기 위해 Social Service는 다음을 제공합니다 REST API:

  • GET /friendships/me - 현재 사용자의 우정을 가져옵니다. Authorization 헤더에 액세스 토큰이 필요합니다.

  • GET /friendships/{other-address}/mutuals - 다른 사용자와의 상호 친구를 가져옵니다. Authorization 헤더에 액세스 토큰이 필요합니다.

WebSocket RPC 서버

Social Service WebSocket API는 우정과 상호 친구를 가져오기 위한 두 가지 메시지 유형을 제공합니다. 먼저 WebSocket 연결을 설정한 다음 해당 메서드를 사용하여 사용자 관련 정보를 스트리밍해야 합니다.

  • GetFriends - 사용자의 친구를 가져옵니다. 사용자 응답 스트림을 반환합니다.

  • GetMutualFriends - 다른 사용자와의 상호 친구를 가져옵니다. 사용자 응답 스트림을 반환합니다.

다음을 참조하세요 friendships.proto 파일 이 메시지 유형에 대한 자세한 내용은

JavaScript 코드 예시

JavaScript를 사용하여 Social Service WebSocket API와 상호작용하려면 앞서 설명한 제공된 RPC 클라이언트를 사용할 수 있습니다. 하지만 직접 구현해야 한다면, 아래에 친구와 상호 친구를 가져오는 방법을 보여주는 코드 예시가 있습니다:

모든 친구 가져오기

import { createRpcClient, createWebSocketsTransport } from '@dcl/rpc/dist/client';
import { FriendshipsServiceDefinition } from './protobuff-types/decentraland/social/friendships/friendships.gen';

const socialClientRpcUrl = 'wss://social.decentraland.org'; // 실제 URL로 바꾸세요
const webSocketsTransport = createWebSocketsTransport(socialClientRpcUrl);
const service = loadService(FriendshipsServiceDefinition, webSocketsTransport);

const response = service.getFriends(Payload.create({ synapseToken }));
for await (const friends of response) {
  processErrors(friends);
  const userList = friends.users?.users ?? [];
  // 친구 목록을 처리합니다
}

상호 친구 가져오기

더 많은 코드 예시와 자세한 내용은 다음을 방문하세요 social-rpc-client-js GitHub 저장소

마지막 업데이트