Channel: blog.atwork.at
Viewing all articles
Browse latest Browse all 1118

Access Yammer from an App–Part 2


In part 1 we created a Yammer App and organized all the necessary App data for the authentication. Now let´s develop a .NET sample app for accessing data from the Yammer network.

Communication with Yammer services

Once the authentication is done we can use the Yammer API REST-Services to get data. The URLs all start with https://www.yammer.com/api/v1/... followed by the service methods like https://www.yammer.com/api/v1/messages.json , users.json, groups.json and so on.

See http://developer.yammer.com/restapi/ for all methods. BTW, some of them are still undocumented…

You can implement your own consumption of the REST-services – or use libraries (as we do below).

REST API Limitations

Calls to the Yammer API calls are subject to rate limiting. These are the maximum calls:

  • Autocomplete: 10 requests in 10 seconds.
  • Messages: 10 requests in 30 seconds.
  • Notifications: 10 requests in 30 seconds.
  • All Other Resources: 10 requests in 10 seconds.

If any rate limits are exceeded the service will result in all endpoints returning a status code of 429 (Too Many Requests). Rate limits are per user per app. So keep these limits in mind.

Get help with .NET libraries

There exist some (open source) libraries to simplify the development process.

I personally like using the Yammer.SimpleAPI from codeplex. This is easy to use and offers the most common tasks. The last version is from October 2013.


Start something

My sample starts with a new C# project in Visual Studio 2013. I downloaded and extracted the Yammer.SimpleAPI and added it to my new console project and added the reference to it like in the following screenshot.


We also added a new class YammerService.cs for the Yammer-specific code.

Start with code and App data

In Program.cs we start with calling the yammerService. The parameters is our data from part 1:

var yammerService = new YammerService(Code, Company, ClientId, ClientSecret);


The Yammer service is created with the app data. Please also note to pass the name of the Yammer network (in my app “atwork.at”). If the administrator is member of many networks we have to specify which network shall be used.

We get a token for the user of the yammerService. This token contains the Client-ID and the user token, so all operations are executed as that user. For accessing all groups we need code similar to here:

var myYammer = new YammerClient(myConfig) { AccessToken = this.AdminToken };
var yammerGroups = myYammer.GetGroups();

Now we can loop through the groups of the network and find our group we want to use.

Tip: When you want to post, like, notify people or reply keep in mind that the user has to be member of the specific group where the action takes place! Yammer does not accept f.i. if user “Toni” likes a message in group “Yammer 101” if “Toni” is no (accepted) member of that group. So you have to take care that the user must be a member of that group before trying to access any information in that group.

After having the specific group “Yammer 101” (we need the group ID which here is 2857304) a message can be sent.

MessagesRootObject message = null;
message = myYammer.PostMessage("This is my first Yammer post!", "2857304");

We recommend to see the source code of the https://yammersimpleapi.codeplex.com/ to try the methods provided by this library.

Background work

What happens in the background when consuming the services? Well, the Yammer.SimpleAPI calls the REST-service in the YammerClient-class. The YammerRequest gets the URL of the required method (f.i. …/groups.json), adds the Authorization Token in the HTTP header and adds the object to request.


The request return is a JSON object… with a lot of data as result.


…which is then deserialized, like the groups here.


That´s the magic of the library. I find it comfortable to use the Yammer.SimpleAPI.

Run it

After running the app we should get a new message in the Yammer network. Sent messages appear instantly in the Yammer group. Yammer informs with a small notification about new posts in the group.


Click the link or refresh the page in the browser. If everything went well we see the new post.


Likes or activities (shown on the right side) can take some seconds to about a minute to be visible.
If different users react the post can become viral. If the actions were made by any other client than the Yammer browser client the source (our app) is shown on the right side near the date and time of the posting.


With the Web APIs Yammer is not a stand alone system. Developers can integrate Yammer services in other systems and communicate with Yammer (and Office 365) users programmatically – which is cool stuff.

Find all Yammer Developer links summarized here:

With that tools have a happy evaluating of the Yammer services!

Viewing all articles
Browse latest Browse all 1118

Latest Images