4 Replies Latest reply on Jan 21, 2016 3:25 AM by vidyashinde

    Follow a person via the osapi?

    audra.b

      Hi,

       

      I notice that you can add users to your streams but can you PUT a person in your "following" list.

      I don't see a create or update method for this unless update Person is the method?

       

      Thanks!

        • Re: Follow a person via the osapi?

          Sadly this is very convoluted, a convenience method would be nice

          var userToFollow; //this is the user we want to follow
          //get the current user      
          osapi.people.getViewer().execute(function (viewerData) {
          
               //retrieve the full user object
               var request = osapi.jive.corev3.people.get({ "id": viewerData.id });
          
                     request.execute(function (fullUser) {
          
                          console.log(fullUser);
                         //get the current users streams
                          var request = fullUser.getStreams();
          
                          request.execute(function (streams) {
          
                              console.log(streams);
                              $.each(streams.list, function (key, value) {
                                  //iterate over the users streams. Hopefully there is one called connections
                                  if (value.source == "connections") {
                                      var array = [userToFollow.resources.self.ref];
                                      var request = value.createAssociations(array);
                                      request.execute(function (association) {
                                          //the newly created stream association
                                          console.log(association);
                                         
          
                                      });
                                  }
                              });
                          });
                      });
                  });
          
          • Re: Follow a person via the osapi?
            vidyashinde

            Hi,

            I tried the following code snippet in a custom tile:

            ...

            $.each(streams.list, function (key, value) { 

                                        //iterate over the users streams. Hopefully there is one called connections 

            var array = ["https://jiveurl/api/core/v3/people/2116"];

                                        if (value.source == "connections") { 

                                           value.createAssociations(array);

            }

            });

            ..

            The error is:

            createAssociations is not a function.

             

            Could you please tell some other way to get this done.

             

            Thanks,

            Vidya Shinde