Get Friend Information
Retrieves the number of friend relationships and pending friend requests.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/friend/v20231201/info - Method:
PUT - Authentication Required: Yes
DeviceInfo Inheritance
The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| table_code | string | Required | Friend table code |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| RelationshipCount | int | Current number of friends |
| PendingCount | int | Number of pending friend requests |
Unity C# Implementation
BaseResponse Class
Base class for all API responses.
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
Field descriptions:
ErrorCode: Error codeMessage: Error messageWithdrawalKey: Key required for recovery if account is in withdrawal grace period (provided only for accounts in withdrawal grace period)BlockKey: Key provided if account is blocked (provided only for blocked accounts)
Friend Information Retrieval Class
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;
}
}
Usage Example
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
void GetFriendInfo()
{
FriendInfo.Req req = new FriendInfo.Req();
StartCoroutine(req.Send(
tableCode: "friend_table",
onSuccess: res =>
{
Debug.Log($"Current number of friends: {res.RelationshipCount}");
Debug.Log($"Pending friend requests: {res.PendingCount}");
// Update UI
UpdateFriendUI(res.RelationshipCount, res.PendingCount);
},
onError: (error) =>
{
Debug.LogError($"Failed to retrieve friend info: [{error.ErrorCode}] [{error.Message}]");
}
));
}
void UpdateFriendUI(int friendCount, int pendingCount)
{
// UI update logic
}
}
Show Notifications
You can use PendingCount to display a notification badge when there are pending friend requests.