본문으로 건너뛰기

친구 정보 조회

친구 관계 수와 대기 중인 친구 요청 수를 조회합니다.

URL 확인

이 API는 service-api.playnanoo.com 도메인을 사용합니다.

API 정보

  • URL: https://service-api.playnanoo.com/friend/v20231201/info
  • Method: PUT
  • 인증 필요: 예
DeviceInfo 상속

이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.

요청 파라미터

파라미터타입필수설명
table_codestring필수친구 테이블 코드

응답 데이터

Res 클래스

필드타입설명
RelationshipCountint현재 친구 수
PendingCountint대기 중인 친구 요청 수

Unity C# 구현

BaseResponse 클래스

모든 API 응답의 기본 클래스입니다.

public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}

필드 설명:

  • ErrorCode: 에러 코드
  • Message: 에러 메시지
  • WithdrawalKey: 탈퇴 유예 상태인 경우 복구에 필요한 키 (탈퇴 유예 중인 계정만 제공)
  • BlockKey: 차단된 계정인 경우 제공되는 키 (차단된 계정만 제공)

친구 정보 조회 클래스

using System;
using System.Collections;
using UnityEngine.Networking;

public class FriendInfo
{
static string path = "https://service-api.playnanoo.com/friend/v20231201/info";

[Serializable]
public class Req : DeviceInfo
{
public string table_code;

public IEnumerator Send(string tableCode, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public int RelationshipCount;
public int PendingCount;
}
}

사용 예제

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
void GetFriendInfo()
{
FriendInfo.Req req = new FriendInfo.Req();

StartCoroutine(req.Send(
tableCode: "friend_table",
onSuccess: res =>
{
Debug.Log($"현재 친구 수: {res.RelationshipCount}");
Debug.Log($"대기 중인 친구 요청: {res.PendingCount}");

// UI 업데이트
UpdateFriendUI(res.RelationshipCount, res.PendingCount);
},
onError: (error) =>
{
Debug.LogError($"친구 정보 조회 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}

void UpdateFriendUI(int friendCount, int pendingCount)
{
// UI 업데이트 로직
}
}
알림 표시

PendingCount를 활용하여 대기 중인 친구 요청이 있을 때 알림 배지를 표시할 수 있습니다.