랜덤 사용자 검색
랜덤으로 다른 사용자를 검색합니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/friend/v20231201/searchRandom - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| table_code | string | 필수 | 친구 테이블 코드 |
| limit | int | 필수 | 검색할 사용자 수 |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| Items | List<ItemModel> | 랜덤 사용자 목록 |
ItemModel 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| OpenId | string | 오픈 ID |
| UserId | string | 사용자 ID |
| Nickname | string | 닉네임 |
| AccessSeconds | int | 마지막 접속 시간 (초 단위) |
| InDate | string | 가입 날짜 |
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 System.Collections.Generic;
using UnityEngine.Networking;
public class FriendRandomSearch
{
static string path = "https://service-api.playnanoo.com/friend/v20231201/searchRandom";
[Serializable]
public class Req : DeviceInfo
{
public string table_code;
public int limit;
public IEnumerator Send(string tableCode, int limit, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;
this.limit = limit;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public List<ItemModel> Items = new List<ItemModel>();
}
[Serializable]
public class ItemModel
{
public string OpenId;
public string UserId;
public string Nickname;
public int AccessSeconds;
public string InDate;
}
}
사용 예제
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
void SearchRandomUsers()
{
FriendRandomSearch.Req req = new FriendRandomSearch.Req();
StartCoroutine(req.Send(
tableCode: "friend_table",
limit: 10,
onSuccess: res =>
{
Debug.Log($"랜덤 사용자 {res.Items.Count}명 검색됨");
foreach (var user in res.Items)
{
Debug.Log($"사용자: {user.Nickname} (ID: {user.UserId})");
Debug.Log($" OpenId: {user.OpenId}");
Debug.Log($" 가입일: {user.InDate}");
}
},
onError: (error) =>
{
Debug.LogError($"랜덤 사용자 검색 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}
}
친구 추천
이 API를 활용하여 "추천 친구" 기능을 구현할 수 있습니다. 검색된 사용자에게 친구 요청을 보낼 수 있습니다.