Skip to main content

Friend Request

Sends a friend request to another user.

URL Confirmation

This API uses the service-api.playnanoo.com domain.

API Information

  • URL: https://service-api.playnanoo.com/friend/v20231201/request
  • 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

ParameterTypeRequiredDescription
table_codestringRequiredFriend table code
open_idstringRequiredOpen ID of the user to send friend request to

Response Data

Res Class

FieldTypeDescription
StatusstringProcessing 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 code
  • Message: Error message
  • WithdrawalKey: 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 Class

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

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

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

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

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 SendFriendRequest(string targetOpenId)
{
FriendRequest.Req req = new FriendRequest.Req();

StartCoroutine(req.Send(
tableCode: "friend_table",
openId: targetOpenId,
onSuccess: res =>
{
Debug.Log($"Friend request sent successfully: {res.Status}");
ShowMessage("Friend request has been sent.");
},
onError: (error) =>
{
Debug.LogError($"Failed to send friend request: [{error.ErrorCode}] [{error.Message}]");
ShowMessage("Failed to send friend request.");
}
));
}

void ShowMessage(string message)
{
// Display UI message
Debug.Log(message);
}
}
OpenID

OpenID can be obtained through the random user search API.

Duplicate Requests

An error may occur if the user is already a friend or if there is a pending request.