Send Media Files
You need to send a POST request to:
https://yoai.yophone.com/api/pub/sendMessage
Request body params format (multipart/form-data)
-
to(required):
The unique identifier for the target chat or the username of the target channel. -
text(required):
The text of the message to be sent. -
file(required):
The path of the image file/files to be sent, up to 10 files, each with a maximum size of 50MB
Supported MIME Types
Image MIME Types
These MIME types represent commonly used image formats:
- image/jpeg – JPEG image format, widely used for photos and web images.
- image/png – PNG (Portable Network Graphics) format, supports transparency and lossless compression.
- image/gif – GIF (Graphics Interchange Format), supports animations and transparency.
- image/webp – WebP image format, developed by Google, provides superior compression with transparency and animation support.
Video MIME Types
These MIME types represent video formats supported for uploads:
- video/mp4 – MP4 (MPEG-4 Part 14), a widely supported video format with good compression.
- video/mpeg – MPEG (Moving Picture Experts Group) video format, used for older digital video and streaming.
- video/webm – WebM format, designed for web-based media delivery with VP8/VP9 codecs.
- video/ogg – Ogg video format, an open-source alternative for multimedia streaming.
- video/quicktime – QuickTime video format developed by Apple, commonly used on macOS and iOS.
Document MIME Types
This MIME type represents supported document formats:
- application/pdf – Portable Document Format (PDF), used for sharing and printing documents with fixed formatting.
Request example
curl -X POST https://yoai.yophone.com/api/pub/sendMessage \
-H "X-YoAI-API-Key: your YoAI api key" \
-F "to=chatId" \
-F "text=message" \
-F "file=@/path/to/image1.jpg" \
-F "file=@/path/to/image2.png"
Success Response
The API returns a JSON object indicating the success of the operation.
{
"code": 200,
"success": true,
"data": null
}
Failure Response
The API returns a JSON object indicating the success of the operation.
{
"code": 200,
"success": false,
"message": "failed to send"
}