【问题标题】:Posting image on yammer using Yammer Javascript SDK使用 Yammer Javascript SDK 在 yammer 上发布图像
【发布时间】:2017-03-20 05:25:20
【问题描述】:

我一直在尝试使用 Yammer Javascript api 在 Yammer 上发布附件。 Yammer 上没有太多关于此的文档。有人可以帮我实现这一目标吗?

谢谢。

【问题讨论】:

    标签: yammer


    【解决方案1】:

    希望这可以帮助您解决问题,

    您可以使用POST:/pending-attachments yammer API 在 yammer 中发布图像。

    但如果您想创建带有图像的 yammer 帖子,POST:/messages.json 可以与附加文件一起使用 - attachment_N or pending_attachment_N 作为多部分表单字段。

    使用此链接获取信息 - Yammer message API

    使用 JavaScript SDK 添加示例代码 -

    let otherFormData = {
        "group_id": groupId,
        "body": message,
        "og_url": postUrl,
        "og_fetch": false,
        "og_title": title,
        "og_image": og_image,
        "og_description": summary,
        "og_object_type": og_object_type,
        "direct_to_user_ids": []
    };
    let formData = new FormData();
    formData.append("attachment1", imgData_Base64, AfileName);
    for (let i in otherFormData) {
        formData.append(i, otherFormData[i]);
    }
    
    window.yam.platform.request({
        url: "messages.json",
        method: "POST",
        data: formData,
        processData: false,
        contentType: false,
        type: 'POST',
        dataType: 'json',
        success: (response) => {
            console.info("The request is successful. ", response); 
        },
        error: (err) => {
            console.info("There is an error in the request.", err);
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多