新しいファイルを添付したコメントの投稿
コメントを投稿し、新しいファイルをアップロードしてコメントに添付するには、ConnectApi.CommentInput オブジェクトと ConnectApi.BinaryInput オブジェクトを作成して postCommentToFeedElement(communityId, feedElementId, comment, feedElementFileUpload) メソッドに渡します。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17String feedElementId = '0D5D0000000KtW3';
18
19ConnectApi.CommentInput commentInput = new ConnectApi.CommentInput();
20
21ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
22ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
23
24textSegmentInput.text = 'Enjoy this new file.';
25
26messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
27messageBodyInput.messageSegments.add(textSegmentInput);
28commentInput.body = messageBodyInput;
29
30ConnectApi.CommentCapabilitiesInput commentCapabilitiesInput = new ConnectApi.CommentCapabilitiesInput();
31ConnectApi.ContentCapabilityInput contentCapabilityInput = new ConnectApi.ContentCapabilityInput();
32
33commentCapabilitiesInput.content = contentCapabilityInput;
34contentCapabilityInput.title = 'Title';
35
36commentInput.capabilities = commentCapabilitiesInput;
37
38String text = 'These are the contents of the new file.';
39Blob myBlob = Blob.valueOf(text);
40ConnectApi.BinaryInput binInput = new ConnectApi.BinaryInput(myBlob, 'text/plain', 'fileName');
41
42ConnectApi.Comment commentRep = ConnectApi.ChatterFeeds.postCommentToFeedElement(Network.getNetworkId(), feedElementId, commentInput, binInput);
43