Accept Friend Request
Accepts a pending friend request.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/friend/v20231201/accept - 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 |
| relationship_code | string | Required | Relationship code of the friend request to accept |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| Status | string | Processing result status |
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 Request Accept Class
using System;
using System.Collections;
using UnityEngine.Networking;
public class FriendAccept
{
static string path = $"https://service-api.playnanoo.com/friend/v20231201/accept";
[Serializable]
public class Req : DeviceInfo
{
public string table_code;
public string relationship_code;
public IEnumerator Send(string tableCode, string relationshipCode, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;
if (!string.IsNullOrEmpty(relationshipCode)) this.relationship_code = relationshipCode;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string Status;
}
}
Usage Example
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
void AcceptFriendRequest(string relationshipCode)
{
FriendAccept.Req req = new FriendAccept.Req();
StartCoroutine(req.Send(
tableCode: "friend_table",
relationshipCode: relationshipCode,
onSuccess: res =>
{
Debug.Log($"Friend request accepted successfully: {res.Status}");
ShowMessage("You are now friends!");
},
onError: (error) =>
{
Debug.LogError($"Friend request acceptance failed: [{error.ErrorCode}] [{error.Message}]");
ShowMessage("Failed to accept friend request.");
}
));
}
void ShowMessage(string message)
{
// Display UI message
Debug.Log(message);
}
}
RelationshipCode
RelationshipCode can be obtained through the pending friend request search API (searchPending).
Refresh Friend List
After accepting a friend request, it's recommended to refresh the friend list to update the UI.