# Use OpenAPI
# Overview
VChatCloud provides not only simple chat functions but also many additional functions in the form of Open APIs. These APIs are included in the VChatCloud API
class within the SDK and can be used by calling functions.
# Chat room information query method
This is a method to query the information in the chat room.
await VChatCloudAPI.getRoomInfo(roomId: "YOUR_CHANNEL_KEY")
Parameter value
Value Identifier Description roomId String ChannelKey
in the chat room created by CMSResult value
Value Identifier Description ChatroomModel? Room information, but people
andlike
must be viewed separately
# Chat room like count query method
This is a method to check the cumulative number of likes in the chat room.
await VChatCloudAPI.getLike(roomId: "YOUR_CHANNEL_KEY");
Parameter value
Value Identifier Description roomId String ChannelKey
in the chat room created by CMSResult value
Value Identifier Description LikeResponseModel? Chatroom Cumulative Likes Inquiry Information
# To add more likes to the chat room
This is a method of adding the number of likes to the chat room.
await VChatCloudAPI.like(roomId: "YOUR_CHANNEL_KEY");
Parameter value
Value Identifier Description roomId String ChannelKey
in the chat room created by CMSResult value
Value Identifier Description LikeResponseModel? Chatroom Cumulative Likes Inquiry Information
# How to query the list of files uploaded to the chat room
Method to query the list of files uploaded to the chat room.
await VChatCloudAPI.getFileList(roomId: "YOUR_CHANNEL_KEY");
Parameter value
Value Identifier Description roomId String ChannelKey
in the chat room created by CMSResult value
Value Identifier Description FileListResponseModel? Arrange uploaded file list
# How to download files uploaded to chat room
A method of fetching and storing data from files uploaded to chat rooms.
The example code below is the code that fetches a list of files and stores the first file on the device.
guard let files = await VChatCloudAPI.getFileList(roomId: "YOUR_CHANNEL_KEY"),
let file = files.data?.list.first else {
return
}
await VChatCloudAPI.downloadFile(file)
2
3
4
5
6
Parameter value
Value Identifier Description model FileItemModel Information on the file to be downloaded, fileNm of the FileItemModel, and fileKey values are required downloadURL String Path to download. If not specified, it will be stored in the app's document folder. If specified, be careful because duplicate files are not checked and overwritten. sharePhotoApp Bool Photos/video files apply sharing to view in the PhotoApp Result value
Value Identifier Description url URL? Path to the saved file
# File URL uploaded to chat room
This is a method to query the address to which a file can be accessed if you just want to show the data of a file uploaded to the chat room without having to store it.
let fileKey = "FILE_KEY"
VChatCloudAPI.loadFileUrl(fileKey)
2
Parameter value
Value Identifier Description fileKey String Unique key to access the file Result value
Value Identifier Description URL? URL Information
# OpenGraph Information Request Method
A method that requests OpenGraph information for the desired URL.
let url = "https://vchatcloud.com"; // Please enter your desired address.
await VChatCloudAPI.openGraph(requestUrl: url);
2
Parameter value
Value Identifier Description requestUrl String URL to query OpenGraph information Result value
Value Identifier Description OpenGraphResponseModel? OpenGraph info
# Google Translation Method
It is a method that translates the desired characters using Google Translation API. To use this function, you can set Google Translation to Use in the chat room setting on CMS, enter the API KEY issued by Google in the Google API KEY
value, click the Modify
button to save it.
A detailed description of the process of obtaining Google API KEY is provided in Using Translation.
Language lists and codes that can be translated
For language codes that can be used for targetLanguageCode
, see Language Support at Google (opens new window).
You can use the VChatCloudAPI.langMap
attribute.
await VChatCloudAPI.googleTranslation(text: "message", targetLanguageCode: "en", roomId: "YOUR_CHANNEL_KEY")
Parameter value
Value Identifier Description text String String to translate targetLanguageCode String Language Code to translate roomId String ChannelKey
of the chat room created by CMS, which must be set to use Google Translation and set the Google API KEY valueResult value
Value Identifier Description GoogleTranslationResponseModel? Message Translation Request Results
# To report a user
This method allows you to report chat room users.
Reported users can check and take action on the chat room monitoring page of VChatCloud CMS.
await VChatCloudAPI.googleTranslation(text: "message", targetLanguageCode: "en", roomId: "YOUR_CHANNEL_KEY")
Parameter value
Value Identifier Description roomId String channel key uniquely issued for each chat room you create banUserClientKey String ClientKey of the user to report banUserNickname String Nickname of the user to report banMessage String Message to report Result value
Value Identifier Description ReportResponseModel? Report Processing Results