user3767531
user3767531

Reputation: 73

Yammer API - Follow person

How to follow a person using yammer API? I know there is follow button provided by Yammer embed but that has its own styling.

Tried creating open graph activity using following code, but this creates an activity and open graph page but does not reflect in "Following" for the specified user.

yam.platform.getLoginStatus(function (response) {

            if (response.authResponse) {
                yam.platform.request({
                    url: "activity.json",
                    method: "POST",
                    data: {
                        "activity": {
                            "actor": {
                                "name": "Kavleen Kaur",
                                "email": "[email protected]"
                            },
                            "action": "follow",
                            "object": {
                             "url": "https://www.yammer.com/abc.com/users/username",
                                "title": "Testing follow Activity!",
                                "type":"person"
                                                                },
                            "message": "Testing follow activity from JS SDK!"
                        }
                    },
                    success: function (msg) { alert("Post was Successful!: " + msg); },
                    error: function (msg) { console.dir(msg); }
                })
            }
        })

Upvotes: 0

Views: 492

Answers (2)

user3767531
user3767531

Reputation: 73

Thanks kendomen for your reply! However, I got unauthorized error due to CORS. Got it to work using following:

yam.platform.request(
   {
       url: "subscriptions"
       , method: "POST"
       , data: {
           target_type: "user",
           target_id: item.SENDERID
       }
       , success: function (msg) {
           alert('Followed');
       }
       , error: function (msg) { }
   });

Upvotes: 1

kendomen
kendomen

Reputation: 778

You can follow a person like this.

function follow(sender_id) {
        yam.request(
          { url: "https://api.yammer.com/api/v1/subscriptions"
              , method: "POST"
              , data: {
                  target_type: "user",
                  target_id: sender_id
              }
              , success: function (msg) {

              }
              , error: function (msg) {  }
        });
    }

Upvotes: 1

Related Questions