Sameer Vaghela
Sameer Vaghela

Reputation: 131

Yammer not working using js

I have tried to display data from yammer using embedded feed using below code then it will work:

yam.connect.embedFeed({ container: "#embedded-feed", network: "elliottaustralia.com", feedType: "group", feedId: "1000157" });

but it will not work for my custom code to fetch data which is as follow:

 <script type="text/javascript">
     var TagDisplayName = "Supplier";
     var GroupId = "1000157";
     yam.connect.loginButton('#yammer-login',
         function (response) {
             if (response.authResponse) {
                 var yUrl = "https://www.yammer.com/api/v1/messages/in_group/" + GroupId + ".json?include_counts=true&threaded=extended&exclude_own_messages_from_unseen=true";
                 yam.request(
                     {
                         url: yUrl,
                         method: "GET",
                         type: "json",
                         success: function (msg) {
                             //Data of Meta tag
                             var meatres = msg.meta;
                             var LastMessageId = meatres.last_seen_message_id;
                         },
                         error: function (msg) {
                             alert("Post was Unsuccessful..." + msg);
                         }
                     }
                 );
             } else {
                 alert('errro');
             }
         }
     );

 </script>

This code will give error.....How to solve it?

Upvotes: 1

Views: 1081

Answers (3)

Keval Solanki
Keval Solanki

Reputation: 128

Dont use full url like "https://www.yammer.com/api/v1/messages/in_group/"

instead use something like "messages/in_group/".

Upvotes: 0

kendomen
kendomen

Reputation: 778

I believe is you use api.yammer.com/v1 it will work. It's been working for me.

            var url = "https://api.yammer.com/api/v1/messages/in_group/" + groupId +".json";

            yam.request(
              { url: url
              , method: "GET"
              , data: {
                                        }
              , success: function (msg) {

Upvotes: 0

Rich Burdes
Rich Burdes

Reputation: 91

Check the Yammer Documentation on this https://developer.yammer.com/yammer-sdks/#javascript-sdk you may need to register your App, then use the updated JS SDK to call it to your page - you'll also probably need the newer api call

<script type="text/javascript" data-app-id="[your app id]" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>

then in your group call its just

yam.platform.request({

url: "messages/in_group/1312007.json?threaded=true"

Hope this helps. Rich

Upvotes: 1

Related Questions