Вопрос

How do you get the group id in Yammer?

I am able to post a message in all of the company as well as to a specific group but i am not able to get the group id of a particular group using Yammer APIs

Find below the code for posting in a particular group where group_id is a string variable whose value I enter manually and want to automate this process.

private void Post(string address)
    {
        System.Uri targetUri = new System.Uri(https://www.yammer.com/api/v1/messages.json?body=HelloTest&group_id=[some_number]&access_token=" + token);
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(targetUri);
        request.Method = "POST";
        request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request); 
    }

// STEP4 STEP4 STEP4
    private void ReadWebRequestCallback(IAsyncResult callbackResult)
    {
        HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
        HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);
        string results;
        using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
        {
            results = httpwebStreamReader.ReadToEnd();
            //TextBlockResults.Text = results; //-- on another thread!
            SkyDriveContent test = new SkyDriveContent();
            test.Name = results;
            str_results = results;

        }
        myResponse.Close();
    }

I saw the documentation but did not find any way to get the list of groups a user is a part of?

Any help would be appreciated!

Это было полезно?

Решение

You should be able to get the list of groups that a user belongs to by making a GET request to https://www.yammer.com/api/v1/groups.json?mine=1. It looks like you are using HttpWebRequest for your client code. If you haven't done so I'd suggest checking out RestSharp as it'll cut down on the amount of code you have to write.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top