### Clone Sample Go Application Repository Source: https://developer.mixi.social/docs/getting-started/quickstart This command clones the Go sample application repository from GitHub, which serves as a starting point for developing applications on the mixi2 Developer Platform. It includes necessary SDKs and API definitions. ```bash git clone https://github.com/mixigroup/mixi2-application-sample-go.git cd mixi2-application-sample-go ``` -------------------------------- ### Go: Install mixi2 Application SDK Source: https://developer.mixi.social/docs/guides/sdk Go プロジェクトに mixi2 application SDK をインストールするための `go get` コマンドです。Go 1.24.6 以上が必要です。 ```bash go get github.com/mixigroup/mixi2-application-sdk-go ``` -------------------------------- ### Configure Environment Variables for Go Application Source: https://developer.mixi.social/docs/getting-started/quickstart This command copies the example environment file to `.env` and instructs the user to edit it. The `.env` file is used to store sensitive authentication credentials such as Client ID, Client Secret, Token URL, and Stream Address, which are required for the application to connect to the mixi2 Developer Platform. ```bash cp .env.example .env ``` -------------------------------- ### Run Go Application Server with gRPC Stream Source: https://developer.mixi.social/docs/getting-started/quickstart This command sequence first sources the environment variables from the `.env` file and then runs the Go application server using the gRPC stream connection method. This method is useful for local testing as it does not require an externally accessible URL. The server will establish a gRPC stream connection to the mixi2 server and start listening for events. ```bash source .env go run cmd/stream/main.go ``` -------------------------------- ### Clone Sample Repository Source: https://developer.mixi.social/docs/getting-started/quickstart Instructions for initializing the application server environment by cloning the provided sample code repository. ```bash git clone cd ``` -------------------------------- ### Setup and Run mixi2 Sample Application (Go) Source: https://developer.mixi.social/docs/guides/sdk Commands to clone the sample repository, configure environment variables, and execute the application in either gRPC stream mode for local development or HTTP Webhook mode for deployment. ```bash git clone https://github.com/mixigroup/mixi2-application-sample-go.git cd mixi2-application-sample-go cp .env.example .env source .env go mod tidy go run cmd/stream/main.go go run cmd/webhook/main.go ``` -------------------------------- ### Token URL and Stream Address Information Source: https://developer.mixi.social/docs/getting-started/quickstart This section provides information about the Token URL endpoint for obtaining access tokens and the Stream Address for gRPC streaming connections. ```APIDOC ## API Endpoints ### Token URL #### Description This endpoint is used to obtain access tokens for API authentication. ### Method GET (Assumed, as it's a URL for retrieval) ### Endpoint `/oauth/token` (Example, actual endpoint may vary) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **access_token** (string) - The obtained access token. - **token_type** (string) - The type of token (e.g., 'Bearer'). - **expires_in** (integer) - The token's expiration time in seconds. #### Response Example ```json { "access_token": "your_access_token_here", "token_type": "Bearer", "expires_in": 3600 } ``` --- ### Stream Address #### Description This is the server address for establishing a gRPC streaming connection. ### Method N/A (This is an address, not an action) ### Endpoint `grpc://your-stream-server.com:port` (Example, actual address will be provided) ### Parameters None ### Request Example None ### Response N/A (This is an address for connection setup) ### Warning Client Secrets are sensitive information. Do not hardcode them in your source code, log them, or commit them to your repository. ``` -------------------------------- ### Go: Authenticator Setup for mixi2 SDK Source: https://developer.mixi.social/docs/guides/sdk mixi2 SDK の認証を行うための Go コードスニペットです。`auth.NewAuthenticator` を使用して認証情報を初期化し、`authenticator.AuthorizedContext` で gRPC リクエスト用のコンテキストを取得します。環境変数からクライアントID、クライアントシークレット、トークンURLを取得します。 ```go package main import ( "context" "log" "os" "github.com/mixigroup/mixi2-application-sdk-go/auth" ) func main() { authenticator, err := auth.NewAuthenticator( os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET"), os.Getenv("TOKEN_URL"), ) if err != nil { log.Fatal(err) } // gRPC リクエスト用のコンテキストを取得 ctx, err := authenticator.AuthorizedContext(context.Background()) if err != nil { log.Fatal(err) } // ctx を使って gRPC リクエストを送信 _ = ctx } ``` -------------------------------- ### RPC InitiatePostMediaUpload Source: https://developer.mixi.social/docs/guides/api-usage Starts the media upload process to obtain an upload URL. ```APIDOC ## RPC InitiatePostMediaUpload ### Description Initializes a media upload session to receive a media_id and a dedicated upload URL. ### Method RPC (gRPC) ### Endpoint `application_apiv1.InitiatePostMediaUpload` ### Parameters #### Request Body - **MediaType** (enum) - Required - Type of media (e.g., TYPE_IMAGE). - **ContentType** (string) - Required - MIME type (e.g., image/jpeg). - **DataSize** (uint64) - Required - Size of the file in bytes. - **Description** (string) - Optional - Alt text or description. ### Request Example ```go resp, err := client.InitiatePostMediaUpload(ctx, &application_apiv1.InitiatePostMediaUploadRequest{ MediaType: application_apiv1.InitiatePostMediaUploadRequest_TYPE_IMAGE, ContentType: "image/jpeg", DataSize: 1024, }) ``` ### Response #### Success Response (200) - **MediaId** (string) - Unique identifier for the media. - **UploadUrl** (string) - URL to perform the actual file upload. ``` -------------------------------- ### GET /posts Source: https://developer.mixi.social/docs/reference/api-document Retrieves a list of posts from the platform. ```APIDOC ## GET /posts ### Description Fetches a list of post information. ### Method GET ### Endpoint /posts ### Response #### Success Response (200) - **posts** (repeated Post) - A list of post objects. #### Response Example { "posts": [ { "id": "post_001", "text": "Example post content" } ] } ``` -------------------------------- ### Initialize Mixi Social Context Source: https://developer.mixi.social/docs/guides/grpc-stream A basic Go package setup demonstrating the import of the required context package for the Mixi Social SDK integration. ```go package main import ( "context" ) ``` -------------------------------- ### GET /GetUsers Source: https://developer.mixi.social/docs/reference/api-document Retrieves user profile information. ```APIDOC ## GET /GetUsers ### Description Retrieves a list of user information. ### Method GET ### Endpoint /GetUsers ### Response #### Success Response (200) - **users** (repeated User) - List of user information. #### Response Example { "users": [ { "id": "user_1", "name": "John Doe" } ] } ``` -------------------------------- ### Post Caption and Spoiler Masking Example Source: https://developer.mixi.social/docs/guides/api-usage This example demonstrates how to set a post caption with a spoiler warning and how to apply masking to sensitive content or spoilers. It uses a specific syntax for defining captions and indicates the use of a masking feature. ```text caption: "映画のネタバレ注意" resp, err := client.CreatePost(ctx, "", "") // Assuming empty strings for other parameters ``` -------------------------------- ### Go SDK for Mixi Webhook Events Source: https://developer.mixi.social/docs/guides/webhook This snippet demonstrates how to import the Go SDK for handling Mixi webhook events. It specifies the path to the webhook and model definitions within the SDK. Ensure the SDK is correctly installed and configured in your Go project. ```go import ( "github.com/mixigroup/mixi2-application-sdk-go/event/webhook" "github.com/mixigroup/mixi2-application-sdk-go/gen/go/social/mixi/application/model/v1" ) ``` -------------------------------- ### Configure Webhook and Event Handling Source: https://developer.mixi.social/docs/guides/webhook This snippet shows how to set up a webhook handler and associate it with a specific event. It includes defining the server port and using a public key for verification. The code demonstrates basic error checking for server startup. ```Go 61:["$","span",null,{\"className\":\"line\",\"children\":[[$\"span\",null,{\"style\":{\"--shiki-light\":\"#032F62\",\"--shiki-dark\":\"#9ECBFF\"},\"children\":\" \\\":8080\\\"\"}],["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\",\"}]]}]\n62:["$","span",null,{\"className\":\"line\",\"children\":[[$\"span\",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\" ed25519.\"}],["$","span",null,{\"style\":{\"--shiki-light\":\"#6F42C1\",\"--shiki-dark\":\"#B392F0\"},\"children\":\"PublicKey\"},["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\"(publicKey),\"}]]}]\n63:["$","span",null,{\"className\":\"line\",\"children\":[[$\"span\",null,{\"style\":{\"--shiki-light\":\"#D73A49\",\"--shiki-dark\":\"#F97583\"},\"children\":\" &\"}],["$","span",null,{\"style\":{\"--shiki-light\":\"#6F42C1\",\"--shiki-dark\":\"#B392F0\"},\"children\":\"MyHandler\"},["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\"{},\"}]]}]\n64:["$","span",null,{\"className\":\"line\",\"children\":["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\" )\"}]}]\n66:["$","span",null,{\"className\":\"line\",\"children\":[[$\"span\",null,{\"style\":{\"--shiki-light\":\"#D73A49\",\"--shiki-dark\":\"#F97583\"},\"children\":\" if\"}],["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\" err \"},["$","span",null,{\"style\":{\"--shiki-light\":\"#D73A49\",\"--shiki-dark\":\"#F97583\"},\"children\":\":=\"}]...\"}]]}]\n67:["$","span",null,{\"className\":\"line\",\"children\":[[$\"span\",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\" log.\"}],["$","span",null,{\"style\":{\"--shiki-light\":\"#6F42C1\",\"--shiki-dark\":\"#B392F0\"},\"children\":\"Fatal\"},["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\"(err)\"}]...\"}]]}]\n68:["$","span",null,{\"className\":\"line\",\"children\":["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\" }\"}]}]\n69:["$","span",null,{\"className\":\"line\",\"children\":["$","span",null,{\"style\":{\"--shiki-light\":\"#24292E\",\"--shiki-dark\":\"#E1E4E8\"},\"children\":\"}\ ``` -------------------------------- ### GET /stamps Source: https://developer.mixi.social/docs/reference/api-document Retrieves a list of official stamps available for the specified language. ```APIDOC ## GET /stamps ### Description Retrieves a list of official stamps. If the language is not specified, the list will be returned empty. ### Method GET ### Endpoint /stamps ### Parameters #### Query Parameters - **official_stamp_language** (LanguageCode) - Optional - The language code for the stamps to retrieve. ### Response #### Success Response (200) - **official_stamp_sets** (repeated OfficialStampSet) - List of official stamp sets in the requested language. ### Response Example { "official_stamp_sets": [] } ``` -------------------------------- ### Initialize Authenticator with Environment Variables in Go Source: https://developer.mixi.social/docs/guides/sdk This Go snippet demonstrates how to initialize an authentication client using credentials retrieved from environment variables. It is intended for secure configuration management in server-side applications. ```go func main() { authenticator, err := auth.NewAuthenticator( os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET"), os.Getenv("TOKEN_URL"), ) if err != nil { // Handle error } ``` -------------------------------- ### Get Stamps API Source: https://developer.mixi.social/docs/reference/api-document Retrieves a list of available stamps. This endpoint does not require any parameters. ```APIDOC ## GET /getstamps ### Description Retrieves a list of available stamps. ### Method GET ### Endpoint /getstamps ### Parameters No parameters are required for this endpoint. ### Response #### Success Response (200) - **stamps** (array of Stamp) - A list of available stamps. #### Response Example ```json { "stamps": [ { "id": "stamp001", "name": "Happy Face", "imageUrl": "https://example.com/stamps/happy.png" }, { "id": "stamp002", "name": "Thumbs Up", "imageUrl": "https://example.com/stamps/thumbsup.png" } ] } ``` ``` -------------------------------- ### Run Webhook Server Source: https://developer.mixi.social/docs/guides/sdk Command to execute the webhook server for deployment purposes. ```bash go run cmd/webhook/main.go ``` -------------------------------- ### GET /media/status Source: https://developer.mixi.social/docs/reference/api-document Retrieves the current upload and processing status for a specific media ID. ```APIDOC ## GET /media/status ### Description Checks the status of a previously initiated media upload using the media ID. ### Method GET ### Endpoint /media/status ### Parameters #### Query Parameters - **media_id** (string) - Required - The ID of the media to check. ### Request Example GET /media/status?media_id=mid_12345 ### Response #### Success Response (200) - **status** (string) - The current processing status of the media. #### Response Example { "status": "processing" } ``` -------------------------------- ### InitiatePostMediaUpload RPC を使用してメディアアップロードを開始する (Go) Source: https://developer.mixi.social/docs/guides/api-usage Go言語で `InitiatePostMediaUpload` RPC を使用して、メディア(画像・動画)のアップロードを開始する方法を示します。`InitiatePostMediaUploadRequest` に `MediaType`, `ContentType`, `DataSize`, `Description` を指定して呼び出します。返り値として `media_id` と `upload_url` を取得します。 ```Go description := "画像の説明(任意)" resp, err := client.InitiatePostMediaUpload(ctx, &application_apiv1.InitiatePostMediaUploadRequest{ MediaType: application_apiv1.InitiatePostMediaUploadRequest_TYPE_IMAGE, ContentType: "image/jpeg", DataSize: uint64(len(imageData)), Description: &description, }) mediaId := resp.MediaId uploadUrl := resp.UploadUrl ``` -------------------------------- ### GET /GetPosts Source: https://developer.mixi.social/docs/reference/api-document Retrieves post information based on a provided list of post IDs. ```APIDOC ## GET /GetPosts ### Description Retrieves post information for a specified list of post IDs. ### Method GET ### Endpoint /GetPosts ### Parameters #### Request Body - **post_id_list** (repeated string) - Required - List of post IDs to retrieve. ### Request Example { "post_id_list": ["post_1", "post_2"] } ### Response #### Success Response (200) - **posts** (repeated Post) - List of retrieved post objects. #### Response Example { "posts": [ { "id": "post_1", "content": "Sample post content" } ] } ``` -------------------------------- ### Go Webhook Server Implementation Source: https://developer.mixi.social/docs/guides/webhook Go SDK を使用して Webhook イベントを受信するサーバーを実装します。このコードは、署名付きリクエストを処理し、受信したイベントをログに記録します。公開鍵は環境変数 `SIGNATURE_PUBLIC_KEY` から取得されます。 ```go package main import ( "context" "crypto/ed25519" "encoding/base64" "log" "os" "github.com/mixigroup/mixi2-application-sdk-go/event/webhook" modelv1 "github.com/mixigroup/mixi2-application-sdk-go/gen/go/social/mixi/application/model/v1" ) type MyHandler struct{} func (h *MyHandler) Handle(ctx context.Context, ev *modelv1.Event) error { log.Printf("Received event: %v", ev) return nil } func main() { publicKeyBase64 := os.Getenv("SIGNATURE_PUBLIC_KEY") publicKey, err := base64.StdEncoding.DecodeString(publicKeyBase64) if err != nil { log.Fatal(err) } server := webhook.NewServer( ":8080", ed25519.PublicKey(publicKey), &MyHandler{}, ) if err := server.Start(); err != nil { log.Fatal(err) } } ``` -------------------------------- ### GET /GetUsers Source: https://developer.mixi.social/docs/guides/api-usage Retrieves user information using the GetUsers RPC method. ```APIDOC ## GET /GetUsers ### Description Retrieves user profile information from the Mixi Social platform. ### Method GET ### Endpoint /GetUsers ### Request Example ```go resp, err := client.GetUsers() ``` ### Response #### Success Response (200) - **resp** (object) - The user information object returned by the RPC call. #### Response Example { "users": [ { "id": "user_123", "name": "Example User" } ] } ``` -------------------------------- ### Displaying Code Snippets with Theming Source: https://developer.mixi.social/docs/guides/sdk This snippet demonstrates how to display code blocks with syntax highlighting and theming support, likely using a library like Shiki. It supports both light and dark themes, with customizable colors for different code elements. ```html ``` ```html
package main

import (
  ""
  "context"
  "log"
  "os"
  ""
``` -------------------------------- ### GET /healthz Source: https://developer.mixi.social/docs/guides/webhook Health check endpoint used to verify the availability of the Webhook server. ```APIDOC ## GET /healthz ### Description Used by the platform or load balancers to check if the Webhook server is operational. ### Method GET ### Endpoint /healthz ### Response #### Success Response (200) - **status** (string) - Returns "OK" or similar status indicator. ``` -------------------------------- ### Go gRPC ストリームでイベントを受信する Source: https://developer.mixi.social/docs/guides/grpc-stream Go SDK を使用して gRPC ストリーム経由でイベントを受信する実装例です。認証情報とストリームアドレスを設定し、イベントハンドラを登録してストリームを監視します。エラーハンドリングとリソースのクリーンアップが含まれています。 ```go package main import ( "context" "crypto/tls" "log" "os" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "github.com/mixigroup/mixi2-application-sdk-go/auth" "github.com/mixigroup/mixi2-application-sdk-go/event/stream" application_streamv1 "github.com/mixigroup/mixi2-application-sdk-go/gen/go/social/mixi/application/service/application_stream/v1" modelv1 "github.com/mixigroup/mixi2-application-sdk-go/gen/go/social/mixi/application/model/v1" ) type MyHandler struct{} func (h *MyHandler) Handle(ctx context.Context, ev *modelv1.Event) error { log.Printf("Received event: %v", ev) return nil } func main() { authenticator, err := auth.NewAuthenticator( os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET"), os.Getenv("TOKEN_URL"), ) if err != nil { log.Fatal(err) } conn, err := grpc.NewClient( os.Getenv("STREAM_ADDRESS"), grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), ) if err != nil { log.Fatal(err) } defer conn.Close() client := application_streamv1.NewApplicationServiceClient(conn) watcher := stream.NewStreamWatcher(client, authenticator) if err := watcher.Watch(context.Background(), &MyHandler{}); err != nil { log.Fatal(err) } } ``` -------------------------------- ### POST /initiate-post-media-upload Source: https://developer.mixi.social/docs/reference/api-document Initiates the upload process for media files intended for posts or messages (room/DM) and provides an upload URL. ```APIDOC ## POST /initiate-post-media-upload ### Description Starts the media upload process and returns a pre-signed URL or endpoint to upload the media content. ### Method POST ### Endpoint /initiate-post-media-upload ### Request Body - **content_type** (string) - Required - The Content-Type of the data being uploaded. ### Response #### Success Response (200) - **upload_url** (string) - The URL to upload the media file to. - **upload_id** (string) - The identifier for the initiated upload session. ``` -------------------------------- ### Get Post Media Status API Source: https://developer.mixi.social/docs/reference/api-document Retrieves the upload and processing status of a specific media item. Requires a media ID to identify the target media. ```APIDOC ## GET /api/media/status ### Description Retrieves the upload and processing status of a specific media item. Requires a media ID to identify the target media. ### Method GET ### Endpoint /api/media/status ### Parameters #### Query Parameters - **media_id** (string) - Required - The ID of the media to check the status for. ### Response #### Success Response (200) - **status** (Status) - The upload/processing status of the media. #### Response Example ```json { "status": "completed" } ``` ``` -------------------------------- ### Clone API Proto Repository Source: https://developer.mixi.social/docs/guides/sdk Command to clone the official Mixi API Protocol Buffer definitions for custom code generation. ```bash # API Proto リポジトリをクローン git clone https://github.com/mixigroup/mixi2-api.git ``` -------------------------------- ### InitiatePostMediaUpload API Source: https://developer.mixi.social/docs/reference/api-document Initiates the process for uploading media associated with a post. This is the first step in a multi-part upload process. ```APIDOC ## POST /api/posts/media/upload/initiate ### Description Initiates the process for uploading media associated with a post. This is the first step in a multi-part upload process. ### Method POST ### Endpoint /api/posts/media/upload/initiate ### Parameters #### Request Body - **post_id** (string) - Required - The ID of the post to which the media will be attached. - **media_type** (string) - Required - The type of media being uploaded (e.g., 'image', 'video'). - **file_name** (string) - Required - The name of the file being uploaded. - **file_size** (integer) - Required - The size of the file in bytes. ### Request Example ```json { "example": { "post_id": "post789", "media_type": "image", "file_name": "my_photo.jpg", "file_size": 1024000 } } ``` ### Response #### Success Response (200) - **upload_id** (string) - A unique identifier for this upload session. - **upload_url** (string) - The URL to which the media parts should be uploaded. #### Response Example ```json { "example": { "upload_id": "upload_abc123", "upload_url": "https://media.mixi.social/upload/upload_abc123" } } ``` ``` -------------------------------- ### POST /media/upload Source: https://developer.mixi.social/docs/reference/api-document Initiates a media upload process by providing the file size, media type, and an optional description. ```APIDOC ## POST /media/upload ### Description Initiates the media upload process and returns an upload URL and media ID. ### Method POST ### Endpoint /media/upload ### Parameters #### Request Body - **data_size** (uint64) - Required - The size of the data to be uploaded in bytes. - **media_type** (Type) - Required - The type of media being uploaded. - **description** (string) - Optional - A description of the media. ### Request Example { "data_size": 1024, "media_type": "image/jpeg", "description": "Profile picture" } ### Response #### Success Response (200) - **media_id** (string) - ID used for tracking status and attaching to posts. - **upload_url** (string) - URL to upload the media data. #### Response Example { "media_id": "mid_12345", "upload_url": "https://upload.example.com/v1/files/mid_12345" } ``` -------------------------------- ### Get gRPC Context and Handle Authorization Errors (Go) Source: https://developer.mixi.social/docs/guides/sdk This Go code snippet demonstrates how to retrieve the context for a gRPC request using an authenticator. It includes error handling for authorization failures, logging fatal errors if the context is not authorized. ```Go ctx, err := authenticator.AuthorizedContext(context.Background()) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Initiate Media Upload with Mixi Social API Source: https://developer.mixi.social/docs/guides/api-usage Demonstrates how to prepare a media upload request by setting a description and calling the InitiatePostMediaUpload function. This returns a response containing the media_id and upload_url required for subsequent steps. ```go description := "画像の説明(任意)" resp, err := client.InitiatePostMediaUpload(ctx, &application_apiv1.InitiatePostMediaUploadRequest{} ``` -------------------------------- ### CreatePost RPC を使用してポストを作成する (Go) Source: https://developer.mixi.social/docs/guides/api-usage Go言語で `CreatePost` RPC を使用して基本的なポストを作成する方法を示します。`client.CreatePost` 関数に `ctx` と `CreatePostRequest` を渡します。`CreatePostRequest` にはポストのテキストを指定します。 ```Go resp, err := client.CreatePost(ctx, &application_apiv1.CreatePostRequest{ Text: "こんにちは!", }) ``` -------------------------------- ### Event Reception Methods Source: https://developer.mixi.social/docs/guides/events Explains the two methods for receiving events: gRPC streams for real-time monitoring and Webhooks for server environments. ```APIDOC ## Event Reception Methods ### Description Events can be received using either the gRPC stream method or the Webhook method. Refer to the respective guides for detailed implementation. ### Methods | Method | Use Case | Guide | | -------------- | --------------------------------------- | ----------------------------------------- | | gRPC Stream | Real-time monitoring, local development | [/docs/guides/grpc-stream](/docs/guides/grpc-stream) | | HTTP Webhook | HTTPS-enabled server environments | [/docs/guides/webhook](/docs/guides/webhook) | ``` -------------------------------- ### SDK Implementation Source: https://developer.mixi.social/docs/guides/webhook Information regarding the implementation of the SDK for interacting with the API. ```APIDOC ## SDK Implementation ### Description Details on how to implement the SDK for integrating with the Developer Mixi Social LLMs TXT services. This section typically includes setup instructions, authentication methods, and code examples for common operations. ### Method N/A (This section describes implementation, not specific API calls) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### POST InitiatePostMediaUpload Source: https://developer.mixi.social/docs/guides/api-usage This endpoint initiates the media upload process. It returns a media_id and an upload_url required for subsequent file transfer operations. ```APIDOC ## POST InitiatePostMediaUpload ### Description Initiates a media upload session. Call this endpoint to obtain a `media_id` and a dedicated `upload_url` for your media content. ### Method POST ### Endpoint /InitiatePostMediaUpload ### Parameters #### Request Body - **description** (string) - Optional - A description of the image being uploaded. ### Request Example { "description": "画像の説明(任意)" } ### Response #### Success Response (200) - **media_id** (string) - Unique identifier for the media session. - **upload_url** (string) - The URL where the media file should be uploaded. #### Response Example { "media_id": "media_12345", "upload_url": "https://upload.mixi.jp/v1/media/12345" } ``` -------------------------------- ### Implement gRPC Stream Watcher in Go Source: https://developer.mixi.social/docs/guides/grpc-stream This snippet demonstrates how to initialize a stream watcher and handle incoming events using a custom handler. It includes error checking and fatal logging if the stream connection fails. ```go if err := watcher.Watch(context.Background(), &MyHandler{}); err != nil { log.Fatal(err) } ``` -------------------------------- ### Initiate Media Upload Request Source: https://developer.mixi.social/docs/guides/api-usage This snippet demonstrates the initialization of an HTTP request for media uploading. It defines the content type as 'image/jpeg' and prepares the request object for the media upload endpoint. ```go req, err := http.NewRequest("POST", upload_url, body) // Set appropriate headers req.Header.Set("Content-Type", "image/jpeg") ``` -------------------------------- ### Create Social Media Post with Client Source: https://developer.mixi.social/docs/guides/api-usage This Go code snippet demonstrates how to create a social media post using a client. It includes parameters for context, application API, post text, and the ID of a post being replied to. The function signature suggests it's part of a larger client library. ```go resp, err := client.CreatePost(ctx, &application_apiv1.CreatePostRequest{ Text: "返信ありがとうございます!", InReplyToPostId: inReplyToPostId, }) ``` -------------------------------- ### Create a post with media attachments using Go Source: https://developer.mixi.social/docs/guides/api-usage Demonstrates how to invoke the CreatePost method in the Mixi Social API client. It requires a context, a pointer to the API request object, and the associated media_id for attachments. ```go resp, err := client.CreatePost(ctx, &application_apiv1.CreatePostRequest{...}) ``` -------------------------------- ### Create Post API Call in Go Source: https://developer.mixi.social/docs/guides/api-usage Demonstrates how to call the CreatePost API in Go, specifying the publishing type and post content. It includes error handling and context management. ```go publishingType := constv1.PostPublishingType_POST_PUBLISHING_TYPE_NOT_PUBLISHING resp, err := client.CreatePost(ctx, &application_apiv1.CreatePostRequest{ Text: "このポストはプロフィールにのみ表示されます", PublishingType: &publishingType, }) ``` -------------------------------- ### Generate Code from Protocol Buffers Source: https://developer.mixi.social/docs/guides/sdk Instructions for generating client code manually from the mixi2 API Protocol Buffers definition using the buf CLI tool. This approach requires manual implementation of authentication, signature verification, and reconnection logic. ```bash git clone https://github.com/mixigroup/mixi2-api.git cd mixi2-api buf generate ``` -------------------------------- ### CreatePost RPC を使用して配信設定付きポストを作成する (Go) Source: https://developer.mixi.social/docs/guides/api-usage Go言語で `CreatePost` RPC を使用して、ポストの配信範囲を制御する方法を示します。`PublishingType` フィールドに `PostPublishingType` を指定します。`POST_PUBLISHING_TYPE_NOT_PUBLISHING` を指定すると、プロフィールにのみ公開されます。 ```Go publishingType := constv1.PostPublishingType_POST_PUBLISHING_TYPE_NOT_PUBLISHING resp, err := client.CreatePost(ctx, &application_apiv1.CreatePostRequest{ Text: "このポストはプロフィールにのみ表示されます", PublishingType: &publishingType, }) ``` -------------------------------- ### POST /CreatePost Source: https://developer.mixi.social/docs/guides/api-usage Creates a new post on the platform. Supports optional masking for sensitive content or spoilers. ```APIDOC ## POST /CreatePost ### Description Creates a new post. Note that `in_reply_to_post_id` and `quoted_post_id` are mutually exclusive and cannot be specified simultaneously. ### Method POST ### Endpoint /CreatePost ### Parameters #### Request Body - **caption** (string) - Optional - The text content of the post, such as spoiler warnings. - **in_reply_to_post_id** (string) - Optional - The ID of the post being replied to. - **quoted_post_id** (string) - Optional - The ID of the post being quoted. ### Request Example { "caption": "映画のネタバレ注意", "in_reply_to_post_id": "12345" } ### Response #### Success Response (200) - **status** (string) - Success message - **post_id** (string) - The ID of the created post #### Response Example { "status": "success", "post_id": "67890" } ``` -------------------------------- ### InitiatePostMediaUploadRequest.Type Source: https://developer.mixi.social/docs/reference/api-document Specifies the type of media to upload. This endpoint is crucial for initiating media uploads, allowing developers to define whether the content is an image or a video. ```APIDOC ## GET /api/media/upload/initiate ### Description Initiates the process for uploading media content, allowing the client to specify the type of media (image or video) to be uploaded. ### Method GET ### Endpoint /api/media/upload/initiate ### Parameters #### Query Parameters - **type** (string) - Required - The type of media to upload. Accepted values are TYPE_IMAGE (1) or TYPE_VIDEO (2). ### Request Example ``` GET /api/media/upload/initiate?type=TYPE_IMAGE ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success or failure of the request. - **message** (string) - Provides details about the response. #### Response Example ```json { "status": "success", "message": "Media upload initiated successfully." } ``` ### Error Handling - **400 Bad Request**: If the 'type' parameter is missing or invalid. - **500 Internal Server Error**: If there is a server-side issue during initiation. ``` -------------------------------- ### Create Post with Media Source: https://developer.mixi.social/docs/guides/api-usage Creates a new post and attaches processed media using the media ID. ```go resp, err := client.CreatePost(ctx, &application_apiv1.CreatePostRequest{ Text: "画像を添付しました!", MediaIdList: []string{mediaId}, }) ``` -------------------------------- ### Webhook URL Configuration Source: https://developer.mixi.social/docs/guides/webhook Instructions on how to configure the Webhook URL, including requirements for the URL. ```APIDOC ## Webhook URL Configuration ### Description This section details the requirements and configuration steps for setting up a Webhook URL. ### Method N/A (Configuration) ### Endpoint N/A (Configuration) ### Parameters #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### URL Requirements - **HTTPS**: Required - **Valid CA Certificate**: A valid CA certificate is mandatory (self-signed certificates are not allowed). - **SDK Usage**: If using the SDK, the path should be `/events` (e.g., `https://YOUR_HOST_NAME/events`). ```