Yammer REST API - Message Likes - yammer

My goal is to get the users who liked each message/comment, and when the like occurred. Currently when querying the Messages endpoint each message has a section called liked_by that contains a count of the total likes on each message/comment, and an array of users that liked the message/comment. However, what I am seeing is that the array with the list of users can not return more than 4 users in the array, even though the message/comment has a total of more than 4 likes. Specifically, if the message/comment has exactly 4 likes, then 4 users are returned in the array. However if the message/comment has greater than 4 likes, only 3 users are returned in the array.
Is there a way to get the Messages endpoint to return all the users who liked each message/comment in the array? Or is there possibly another way to pull message/comment likes with what message/comment was liked, by what user it was liked by, and at what time the like occurred?
Thanks!

The Yammer API will only return users that have liked a message as follows:
1 - If three people like a message, display all three
2 - If four people like a message, display all four
3 - If five people or more like a message, display three and use the front-end code to say "x, y, z and n others liked this" (where n = total number of likes minus 3)
There is no workaround that I can find to display all the users that liked a particular message.

four years later there is a workaround for this, please see this answer:
See here for further details - https://developer.yammer.com/docs/usersliked_messagemessage_idjson

Related

how to create logic that returns a certain number of cards based on the output of an API

I am calling an API where i get a set of information back as an object (e.g. screenshot). Because the value “bill_number” equals 2, I then want to create some logic that means that: because 2 instances of bills have been returned from the API (bill_number == 2) the next response from the bot should be 2 hero cards (in a carousel) with each card displaying different pieces of information: Card 1 to display the values of bill number 1 and card 2 to display the values for bill number 2. Similarly, if the value of "bill_number” returned when calling the API again was 4, i want the logic to then create 4 cards. I am unable to find the logic to create this.
 (see image)
information returned from api
It sounds like you need to use dynamic adaptive card to achieve this outcome.
I did find this which appears to be looking to do something similar - https://github.com/microsoft/BotFramework-Composer/issues/3674

Recommended way of getting student assignments in Google Classroom API

Trying to get all assignments for a given student but cannot find a reliable (fast) way to do it.
It seems like the only way would be:
Get the student courses via courses.list
Loop through the courses list and call courses.courseWork.list for each
Say that on average a student has 10 courses, then 10 requests have to be made. But this takes a while and is kind of overkill...
I would like to know if I am missing something, is there a better way?
I guess you are the user who posted the last comment in this Feature Request. Unfortunately the method you described is the only way.
For someone who faces the same issue, in the Feature Request, you can click on the star next to the issue number to receive updates and to give more priority to the Request.

Mailchimp members activity

I've got some kind of script. Goal is:
Get Mailchimp Lists
For each list get members
For each member get activity
Store it
Does anyone know - if there any way to not use one API call for each member to get his activity?
I've got around 28 000 members.
28 000 API calls - seems as bad as it can be.
I've tried to get Lists Activity, but no way, it is always empty. So I really have to get exactly members activity.
I'm currently attempting to do something very similar and there is a workaround, although I am not sure how feasible it is. Basically, you can do it through reports, email activity:
http://developer.mailchimp.com/documentation/mailchimp/reference/reports/email-activity/
The challenge here will be that you will try to pull 28.000+ records at a time, therefore it will take a long time. From my brief calculations it can take up to 1 minute per 1000 records (you will need to loop through 1000 records at a time, otherwise it will most likely time out).
The larger problem is maintaining this 'database', if you have activity constantly happening (i.e. opens/clicks/bounces) then you will need to pull the whole campaign activity again and update wherever you store it. I've been trying to find a workaround with no success. You could use the 'since=2017-10-07T00:00:00+00:00' parameter, however it still returns a blank list when there is no activity unfortunately. If only 1000 members are actually active, it will return 27.000 rows of no activity. It would be great if there would be another parameter we could potentially apply to return only emails where there was an action.
Please let me know if you find a better solution.
P.S. - it might be worth reaching out to mailchimp support for this
Update - you can use the Mailchimp Export api: https://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-the-export-api/ and extract the email activity. I had huge issues unpacking it, please follow the links below: Decode text response from API in Python 3.6 and Separate pd DataFrame Rows that are dictionaries into columns . Let me know if you have any other questions.

Yammer API - how to get full list of likes using messages endpoint?

I've noticed that the messages.json endpoint doesn't seem to return all the data needed to show the likes per message.
Specifically, two things seem to be happening:
List of likers only has info on 3 users.
The avatar images for the likers is not always available when looking up through the "references" array.
We're using the JS SDK for our integration.
Thanks
https://api.yammer.com/api/v1/users/liked_message/:Message_id.json should return user properties of LIKERS, a count of all LIKERS should give you the total LIKES per message.
In practice, you'd need to call the messages endpoint, get the message id, then pass it into users/liked_message/:Message_id.json programatically.
See here for further details - https://developer.yammer.com/docs/usersliked_messagemessage_idjson

Advertising rotation: What's the best to determine when and what ad should be displayed on the page?

A client I'm creating a site for wants a custom advertising "engine". The plan is to have a few ads on the site and fill the rest with Google Adsense until all the spots are full.
My problem is how to determine which ad to dipslay. (Assume for now that I only have 1 ad placement.) My thinking was I'd have a table with:
year
month
impressions for the month (0 for unlimited)
used impressesion
clients
HTML code to display ad
I could do something like to get the ads:
SELECT *
FROM ad
WHERE impressions > used_impressions
OR impressesions = 0
ORDER BY RAND()
LIMIT 1
But, say I have 3 ads:
1 ad -- 5000 impressions
1 ad -- 5000 impressions
Google Adsense filling the reaminder of the sites hits
Statistically speaking all 3 ads would be displayed an equal number of times. By the end of the first week and 15000 hits on the site, the first 2 ads would have used all of their impressions and the remaining 3+ weeks of the month and not be displayed again; only Google Adsense would be displayed.
How do I space out the ads so they are spread out over the month?
I am using LAMP.
Darryl,
I would suggest breaking the ad impressions down by day, so that
1 ad -- 5000/(monthsToDisplay/30)
This will give you a number of impressions you need to serve per day, and should help distribute things nicely over the weeks. So lets assume you have these variables or database fields:
totalImpressions = 5000;
dailyImpressions = totalImpressions/(monthsToDisplay/30)
Then you could do something like:
SELECT * FROM ad WHERE (totalImpressions > used_impressions AND dailyImpressions > used_dailyImpressions) OR impressesions = 0 ORDER BY RAND() LIMIT 1
Hope this made sense - it's early morning here, but I will check back later!
Berti
You are talking about AdServing type of technology. There are various ways to determine which ad should be shown.
The Event delivery scenario described above is generally called "Even Flighting". Meaning, that an ad will be served evenly for the duration of the campaign. This is not always best. Sometimes advertisers just want delivery.
"Even Flighting" should not be implemented on its own. You should first implement "Frequency Capping". This means that the same ad is not served to the same person more than a set amount of times. Example, if a user doesn't click on an ad after 5 times of seeing it, they are just not going to click. In this event, you should serve another ad.
Combining this method, you would determine how many impressions you need to serve for the day.. then on a per user basis.. determine how many times the user has seen the ad. If they are eligable to see it again, then show it.. otherwise.. show adsense.
However, you would be better off suggesting a free ad server like Google Ad Manager or OpenX. They have already solved all of these problems and there is no point re-inventing the wheel.

Resources