1

我可以使用此链接从 yammer 私人组获取消息 https://www.yammer.com/api/v1/messages/in_group/3248147.json?access_token= + rawtoken)

但我使用相同的链接将消息发布到 yammer 中的私人组,为此我编写了以下代码。但它仅表现为 get 方法,我无法将消息发布到私人组。

WebClient wc = new System.Net.WebClient();

                Uri uri = new Uri("https://www.yammer.com/api/v1/messages/in_group/3248147.json?access_token=" + rawtoken);
                student ns = new student();
                // wc.Headers["Authorization"] = "Bearer" + rawtoken;  //use discoEN token here
               // String data1 = "group-id=" + ns.group_id + "&body=" + ns.body;
                String data = "body=" + "hello";
                wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted);
                wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                wc.Encoding = Encoding.UTF8;
                wc.UploadStringTaskAsync(uri,"post",data);

 private void wc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
    {
        MessageBox.Show(e.Result);
    }
4

1 回答 1

1

像下面那样构造您的帖子网址,并使用 Bearer 令牌格式将身份验证保留在标题中。

请注意,正文以 post 格式包装在查询中。

auth = "持有者" + 令牌

HTTParty.post("https://www.yammer.com/api/v1/messages.json?group_id=3248147",
              { 
                :headers => { "Authorization" => auth},
                :query => {"body" => 'hello' }
  })
于 2014-08-27T19:04:55.393 回答