Enhancing the Yammer Search Results and Messages Samples and Deserialization


Just as kind of strange coincidence, I was in working on some Yammer message JSON goo and realized that there were actually a couple of other important data elements that comes down in the JSON payload when you get a collection of messages from REST.  That includes both querying for messages directly, as well as getting a collection back in search results.  In addition to the messages themselves, there's also some info that can be used with the realtime API, as well as what it calls "references".  The beauty of the references content is that it includes information about each user referenced in the collection of messages that are returned.  I missed this the first time around, just one of the dangers at trying to stare at about 4k of JSON and hoping to extract everything useful out of it.  Mucho love here to Fiddler and it's JSON parser for snapping me out of it.  🙂

If you read the blog post on integrating search results here:  http://blogs.technet.com/b/speschka/archive/2014/03/11/integrating-yammer-and-sharepoint-2013-search-results.aspx – you saw that when I got a list of search results back, I actually made a second call back to Yammer for each one to get information about the user associated with the message.  By pulling in the references information I no longer need to make those additional round trips now.

So there are two things I wanted to briefly touch on here.  First, I've updated the definition of the YammerMessages class; the JSON returned from Yammer is serialized into this class.  I've now added additional properties into which the realtime and references information is hydrated when you call GetInstanceFromJSON.  I've attached the updated class to this posting so you can download it and use it in your projects and then you will "automatically" get this new goodness.  The second thing is I rewrote the section of code in the search WebAPI service I had so that it uses that References collection now instead of calling back to Yammer.  I'm just going to paste in here the chunk of code from that solution that has changed; if you are going to build on that example I linked to above just plug in this new code:

foreach (YammerMessage ym in ysr.Messages.Messages)

{

                    #region used this method to get the user info by querying Yammer again

                   ////get the Yammer User that posted each message so we can pull in

                   ////their picture url

                   //string userUrl = oneUserUrl.Replace("[:id]", ym.SenderID);

                   //response = YammerREST.MakeGetRequest(userUrl, accessToken);

                   //YammerUser yu = YammerUser.GetInstanceFromJson(response);

                   #endregion

                   var yUser = from YammerMessagesReferences yr in ysr.Messages.References

                               where ym.SenderID == yr.ID

                               select yr;

                   YammerMessagesReferences ymr = yUser.First<YammerMessagesReferences>();

                   //add a new search results

                   //finds.Add(new SearchResult(yu.FullName, yu.WebUrl, yu.FirstName, ym.MessageContent.RichText, yu.PhotoUrl, DateTime.Parse(ym.CreatedAt), ym.WebUrl));

                    finds.Add(new SearchResult(ymr.FullName, ymr.WebUrl, ymr.UserName, ym.MessageContent.RichText, ymr.MugshotUrl, DateTime.Parse(ym.CreatedAt), ym.WebUrl));

                    iCount += 1;

                   if (iCount == 3)

                       break;

}

YammerMessages.cs.txt

Comments (7)

  1. alexandrad9x says:

    Tao http://dichvuketoanlongbien.com/
    Rủa
    http://dichvuketoanlongbien.com/a2-96-dich-vu-ke-toan-tron-goi.html
    Thằng http://dichvuketoanlongbien.com/a2-98-dich-vu-ke-toan-thue.html
    Cờ
    http://dichvuketoanlongbien.com/a2-103-dich-vu-bao-cao-tai-chinh.html
    http://dichvuketoanlongbien.com/a2-97-dich-vu-quyet-toan-thue.html
    Nào
    http://dichvuketoanlongbien.com/a2-114-dich-vu-ke-toan-tai-29-quan-huyen.html
    Soi
    http://dichvuketoanlongbien.com/i780-dich-vu-ke-toan-thue-tron-goi-tai-bac-ninh.html
    Tài
    http://dichvuketoanlongbien.com/i779-dich-vu-ke-toan-thue-tron-goi-tai-bac-giang.html
    Khoản
    http://dichvuketoanlongbien.com/i778-dich-vu-ke-toan-thue-tron-goi-tai-phu-tho.html

    http://dichvuketoanlongbien.com/i781-dich-vu-ke-toan-thue-tron-goi-tai-hung-yen.html
    Link
    http://dichvuketoanlongbien.com/i782-dich-vu-ke-toan-thue-tron-goi-tai-vinh-phuc.html
    Của
    http://dichvuketoanlongbien.com/i783-dich-vu-ke-toan-thue-tron-goi-tai-hai-phong.html
    Tao. http://www.trungtamketoan.com.vn/
    Chúng
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-ha-noi.html
    Mày
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-tp-hcm.html
    Đủ
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-quang-ninh.html
    Trình
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-hai-duong.html
    Thì
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-bac-giang.html
    Tự
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-bac-ninh.html
    Đi
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-hai-phong.html

    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-nam-dinh.html
    Làm.
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-thai-binh.html
    Việc
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-thanh-hoa.html

    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-vinh-phuc.html
    Phải
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-hung-yen.html
    Rẻ
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-phu-tho.html
    Rách
    http://www.trungtamketoan.com.vn/p/trung-tam-dao-tao-ke-toan-tai-binh-duong.html
    Như http://www.tosvn.com
    Thế. http://iketoan247.blogspot.com
    Loại http://tailieuveketoan.blogspot.com
    Chó http://mauhinhnendep.blogspot.com
    Má. http://www.tosvn.com/search/label/Hack%20CF
    Tao http://www.tosvn.com/search/label/Hack%20AvatarStar
    Rủa http://www.tosvn.com/search/label/Hack%20Warcraft-Dota2
    Những http://hocketoan360.com/category/tai-lieu-ke-toan/
    Thằng http://iketoan247.blogspot.com/search/label/thong-tin-kinh-te
    Soi http://iketoan247.blogspot.com/search/label/tin-bai-ve-thue
    Tao http://hoclamketoan.edu.vn/
    Sẽ http://hoclamketoan.edu.vn/category/khoa-hoc-ke-toan
    Tan http://hoclamketoan.edu.vn/category/dich-vu-ke-toan
    Cửa http://hoclamketoan.edu.vn/category/hoc-lam-ke-toan
    Nát http://hoclamketoan.edu.vn/category/tai-lieu-ke-toan
    Nhà http://hocketoan360.com/
    Haha http://hocketoan360.com/category/khoa-hoc-ke-toan/
    http://hocketoan360.com/category/dich-vu-ke-toan/

  2. ASFD says:

    http://www.shopbestgoods.com/
    http://www.nike-jordanshoes.com/
    http://www.beatsbydreoutlet.net/
    http://www.michaelkorsus.com/
    http://www.polo-tshirts.com/
    http://www.northsclearance.com/
    http://www.ralph-laurensale.com/
    http://www.gucci-shoesuk2014.com/
    http://www.michael-korsusa.com/
    http://www.polo-outlets.com/
    http://www.ralphslauren.co.uk/
    http://www.marcjacobsonsale.com/
    http://www.mcmworldwides.com/
    http://www.salongchamppairs.com/
    http://www.canada-gooser.com/
    http://www.burberryoutlet2014.com/
    http://www.michaelkors.so/
    http://www.hermes-outletonline.com/
    http://www.oakley-sunglassoutlet.com/
    http://www.north-faceoutlets.net/
    http://www.moncler-clearance.com/
    http://www.woolrich-clearance.com/
    http://www.barbour-jacketsoutlet.com/
    http://www.moncler-jacketsoutletonline.com/
    http://www.monsterbeatsbydres.net/
    http://www.louis-vuittonblackfriday.com/
    http://www.lv-guccishoesfactory.com/
    http://www.mcmoutlet-jp.com/
    http://www.cheapdiscountoutlet.com/
    http://coachoutlet.iwopop.com/
    http://www.coachsfactoryoutlet.com/
    http://www.coach-blackfriday2014.com/
    http://www.coach-storeoutletonline.com/
    http://www.coach-factorysoutletonline.com/
    http://www.coachccoachoutlet.com/
    http://www.coach-factories.net/
    http://www.coach-pursesoutletonline.com/
    http://www.llouisvuitton-factory.net/
    http://www.coach-outletsusa.com/
    http://www.mksfactoryoutlet.com/
    http://www.zxcoachoutlet.com/
    http://www.mischristmas.com/
    http://www.misblackfriday.com/
    http://www.bestcustomsonline.com/
    http://www.newoutletonlinemall.com/
    http://www.clickmichaelkors.com/
    http://www.cmichaelkorsoutlet.com/
    http://www.ralphlaurenepolo.com/
    http://michaelkorsoutlet.mischristmas.com/
    http://mcmbackpack.mischristmas.com/
    http://monsterbeats.mischristmas.com/
    http://northfaceoutlet.mischristmas.com/
    http://mk.misblackfriday.com/
    http://coachoutlet.misblackfriday.com/
    http://coachfactory.misblackfriday.com/
    http://uggaustralia.misblackfriday.com/
    http://coachpurses.misblackfriday.com/
    http://coachusa.misblackfriday.com/
    http://coach.misblackfriday.com/
    http://michaelkorss.misblackfriday.com/
    http://michaelkors.misblackfriday.com/
    http://airmax.misblackfriday.com/
    http://michael-kors.misblackfriday.com/

    http://t.co/1PJuejI1ys
    http://t.co/FYm2MxWwLM
    https://twitter.com/CoachOutlet2014
    https://www.facebook.com/pages/Coach-Factory-Outlet-Online-Store-Michael-Kors-Outlet-Online-Sale-75-Off/712060898859091
    https://www.facebook.com/pages/Ralph-Lauren-Polo-Outlet-Online-Sale/1404100279810690

  3. m88 says:

    So back to the question from above. Where is the poll? According to the writer, it may stem from a campaign roadmap for Ronaldo won the Golden Ball 2014 Look out for the past few days Real members are trying to "pump" for Ronaldo all the way down. Karim
    Benzema, Toni Kroos, Gareth Bale, Luka Modric … Ronaldo praised as a superhero. Carlo Ancelotti called
    http://www.m88no.com/Main/Home.aspx?affiliateId=99156">M88 Ronaldo is the best player he had ever trained.
    http://link138vip.blogspot.com" title="138 bet">138 bet |
    http://linkbodog88vip.blogspot.com" title="bodog88">bodog88 |
    http://link188betvip.blogspot.com" title="188bet">188bet |
    http://dafa-bet.blogspot.com" title="dafa bet">dafabet |
    http://dafa-bet.blogspot.com" title="fun88">fun88 |
    http://link166betvip.blogspot.com" title="166bet">166bet |
    http://linkm88vip.blogspot.com" title="m88">m88 |

    "Explosive jubilant" is "super brokers" Jorge Mendes. He told Ronaldo cost £ 1 billion and is the greatest player in the history of soccer M88. He also appears to leave little friend Jose Mourinho few sentences are not they?!.

    Mourinho, though there is still time feud with Ronaldo at Real (much media coverage about it), but still compliment M88 Ronaldo as a special star, Zinedine Zidane effect as in the days before the French team. Be compared with the legendary Zidane, a lawn illustrious
    European world (both club level and national team shirt color), the right is too monumental to the "post-born" as Ronaldo.

  4. SDFSD says:

    http://www.burberryfactorys.com/
    http://www.shophandbagsonline.com/
    http://www.official-coachoutlet.com/
    http://www.barbour-factory.com/
    http://www.burberry-outlet2014.com/
    http://www.gucci-factory.com/
    http://www.marcjacobsonsale.com/
    http://www.mcmworldwide.ca/
    http://www.guccishoes-uk.com/
    http://www.kate-spades.com/
    http://www.louisvuittonas.com/
    http://www.lv-guccishoesfactory.com/
    http://www.official-mkoutlets.com/
    http://www.official-pradaoutlet.com/
    http://www.michael-korsusa.net/
    http://www.north-facesoutlet.com/
    http://www.moncler-clearance.com/
    http://www.north-faceclearance.com/
    http://www.clothes-mall.com/
    http://www.polo-outlets.com/
    http://www.ralphlauren.so/
    http://www.ralphlaurentshirts.com/
    http://www.ferragamos.in.net/
    http://www.longchampsoutlet.com/
    http://www.abercrombiee.com/
    http://www.barbour-jacketsoutlet.com/
    http://www.michael–korsonline.com/
    http://www.thenorthface.so/
    http://www.cheapuggsbootso.com/
    http://www.beatsbydreoutlet.net/
    http://www.tommyhilfiger.in.net/
    http://www.ralphslauren.co.uk/
    http://www.michaelkors.so/
    http://www.oakleyssunglassoutlet.com/
    http://www.warm-boots.com/
    http://www.tory-burches.com/
    http://www.woolrich-clearance.com/
    http://www.tommy-hilfigeroutlet.com/
    http://www.uggboots-factory.com/
    http://www.official-northfaceoutlet.com/
    http://www.nike-jordanshoes.com/
    http://www.monsterbeatsbydres.net/
    http://www.canada-gooser.com/
    http://www.bestcustomsonline.com/
    http://coach.mischristmas.com/
    http://www.coach-blackfriday2014.com/
    http://www.coachccoachoutlet.com/
    http://www.coach-clearance.com/
    http://www.coach-factories.net/
    http://www.louisvuittonsas.com/
    http://www.coach-factorysoutlet.com/
    http://www.coachlosangeles.com/
    http://www.coachoutletstates.com/
    http://www.coach-pursesoutlets.com/
    http://www.hermes-outletonline.com/
    http://www.misblackfriday.com/
    http://www.mischristmas.com/
    http://www.mmoncler-outlet.com/
    http://www.newoutletonlinemall.com/
    http://www.ralphlaurenepolo.com/
    http://www.zxcoachoutlet.com/
    http://www.embereso.com/
    http://www.varmoweuts.com/
    http://www.bootiexew.com/
    http://www.mistuesday.com/
    http://www.towednesday.com/
    http://www.misblackfriday.com/uggsale.html
    http://www.mischristmas.com/uggboots.html
    http://www.clickmichaelkors.com/
    http://www.newoutletonlinemall.com/coachoutlet.html
    http://www.zxcoachoutlet.com/coachoutletonline.html
    http://michaelkorsoutlet.mischristmas.com/
    http://mcmbackpack.mischristmas.com/
    http://monsterbeats.mischristmas.com/
    http://northfaceoutlet.mischristmas.com/
    https://twitter.com/CoachOutlet2014
    https://www.facebook.com/coachoutletstoreonline
    https://www.facebook.com/ralphlaurenoutletonline
    http://www.misblackfriday.com/superstar.html
    http://www.mischristmas.com/blackfriday2015.html
    https://www.facebook.com/burberryoutlettoryburchoutlet/

  5. m88 says:

    m88 : http://m88en.com
    M88.com offer online sports games Asia, Sports Betting Asia, Sports Betting Sites Asia.

    m88asia : http://m88en.net
    Link to M88BET phone: m88en.com. – Register and Open Betting Account and Membership M88BET.

    m88bet : http://www.linkm88vip.com
    MANSION88 the house is one of the largest and most prestigious. Appeared quite early in the Asian market, the so-MANSION88 currently attracts more players.

    link m88 : http://m88wiki.com
    Home the M88 is the official sponsor of the football club in the Premier League
    Wish you happy with the new M88
    m88 casino online : http://m88free.com

    Modern Thai restaurant combines outstanding traditional cuisine and a subtle modern decor with a warm welcoming ambience. Thai Restaurants in Brisbane :
    http://www.watersidethainoodles.com.au , traveller reviews of Brisbane Thai restaurants and search by price, location, and more..