如何向yammer私人组发帖子

时间:2013-11-20 06:08:37

标签: windows-phone-8 yammer

我可以使用此链接从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);
    }

1 个答案:

答案 0 :(得分:1)

如下所示构建您的帖子网址,并使用Bearer令牌格式将auth保留在标头中。

请注意,body以post格式包装在查询内部。

auth =" Bearer" +令牌

HTTParty.post("https://www.yammer.com/api/v1/messages.json?group_id=3248147",
              { 
                :headers => { "Authorization" => auth},
                :query => {"body" => 'hello' }
  })