跳转到主要内容

删除好友

删除已注册的好友。

URL 确认

此 API 使用 service-api.playnanoo.com 域名。

API 信息

  • URL: https://service-api.playnanoo.com/friend/v20231201/delete
  • Method: PUT
  • 需要认证: 是
DeviceInfo 继承

此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性将自动包含。

请求参数

参数类型必填说明
table_codestring必填好友表代码
relationship_codestring必填要删除的好友的关系代码

响应数据

Res 类

字段类型说明
Statusstring处理结果状态

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 FriendDelete
{
static string path = "https://service-api.playnanoo.com/friend/v20231201/delete";

[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;
}
}

使用示例

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
void DeleteFriend(string relationshipCode)
{
FriendDelete.Req req = new FriendDelete.Req();

StartCoroutine(req.Send(
tableCode: "friend_table",
relationshipCode: relationshipCode,
onSuccess: res =>
{
Debug.Log($"친구 삭제 성공: {res.Status}");
},
onError: (error) =>
{
Debug.LogError($"친구 삭제 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}
}
无法恢复

删除好友后无法撤销。建议在删除前向用户进行确认。